将sqlalchemy连接到MSAccess [英] connecting sqlalchemy to MSAccess

查看:106
本文介绍了将sqlalchemy连接到MSAccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用SQLAlchemy连接到MS Access?在他们的网站上,它说连接字符串是access + pyodbc.这是否意味着我需要pyodbc进行连接?因为我是新手,所以请保持温柔.

How can I connect to MS Access with SQLAlchemy? In their website, it says connection string is access+pyodbc. Does that mean that I need to have pyodbc for the connection? Since I am a newbie, please be gentle.

推荐答案

从理论上讲,这是通过create_engine("access:///some_odbc_dsn")实现的,但是自从SQLAlchemy 0.5以来,Access后端就一直没有使用过,也不清楚当时的效果如何(这就是为什么在 http://docs.sqlalchemy.org/en/latest/core/engines.html#supported-databases -开发"的意思是该方言的开发版本存在,但尚未可用").只是没有足够的兴趣/志愿者来保持这种方言的运行. (如果有,则您将在 http://docs上看到它.sqlalchemy.org/en/latest/dialects/access.html ).

In theory this would be via create_engine("access:///some_odbc_dsn"), but the Access backend hasn't been in service at all since SQLAlchemy 0.5, and it's not clear how well it was working back then either (this is why it's noted as "development" at http://docs.sqlalchemy.org/en/latest/core/engines.html#supported-databases - "development" means, "a development version of the dialect exists, but is not yet usable"). There's just not enough interest/volunteers to keep this dialect running right now. (when/if it is, you'll see it at http://docs.sqlalchemy.org/en/latest/dialects/access.html).

您现在最好的访问方式是将数据导出到SQLite数据库文件(或者当然是其他数据库,尽管SQLite至少是基于文件的),然后再使用它.

Your best bet for Access right now would be to export the data into a SQLite database file (or of course some other database, though SQLite is file-based in a similar way at least), then use that.

更新,2019年9月:

已恢复sqlalchemy-access方言.详细信息此处.

The sqlalchemy-access dialect has been resurrected. Details here.

用法示例:

engine = create_engine("access+pyodbc://@some_odbc_dsn")

这篇关于将sqlalchemy连接到MSAccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆