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

查看:41
本文介绍了将 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 - "development" 的意思是,"存在方言的开发版本,但尚不可用").现在没有足够的兴趣/志愿者来保持这种方言的运行.(当/如果是,您将在 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).

您现在对 Access 的最佳选择是将数据导出到 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天全站免登陆