【发布时间】:2015-03-18 22:29:21
【问题描述】:
我发现尽管只支持 sqlite ,但 pandas.io.sql.read_sql 方法可以很好地通过查询 Microsoft Access 数据库来创建数据框。
driver_string="DRIVER={Microsoft Access Driver (*.mdb)}"
file_string = "DBQ="+"test.mdb"
connection_string = ";".join([driver_string, file_string])
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
df = pd.read_sql("SELECT * FROM testTable", con=cnxn, index_col = ["indexCol"])
我对读取数据更感兴趣,不太可能写回数据库。我还用包括连接在内的更复杂的查询对此进行了测试,它似乎运行良好。
谁能告诉我这里是否有危险?这似乎比使用 SQLAlchemy(也不支持 Access)简单得多。
如果有人有任何见解,我将不胜感激。
【问题讨论】: