刚开始学熊猫,就在“读sql”的时候摔倒了:
在我的代码中有多个create语句,使用“read_sql_query”执行这些语句会使作业变得多余,例如:
import pandas as pd
import sqlite3
con = sqlite3.connect("/Users/sqlite_example.db3")
query_1 = ("Create table temp_1")
pd.read_sql_query(query_1,con)
query_2 = ("Create table temp_1")
pd.read_sql_query(query_2,con)
query_3 = ("Create table temp_3")
pd.read_sql_query(query_3,con)
我的问题是:
我试着查看文档和门户网站,但没有找到这样的东西。在“read_sql_query”中,每次必须传递“query,con”,否则如果不这样做,则会出现错误。在
请帮助理解传递多个查询和建立连接只需一次而不是多次的概念和方法。在
我希望这也能帮助那些在不久的将来面临类似问题的人。在
这应该能奏效。在
{cd1>中使用多个语句执行同一个查询。在
相关问题 更多 >
编程相关推荐