Using SQL Alchemy and pyodbc with IronPython 2.6.1

☆樱花仙子☆ 提交于 2019-11-30 16:40:17

its very likely that pyodbc is not compatible with IronPython, as it was designed for usage with cPython.

IronPython certainly has some kind of ODBC (actually, ADO.net seems like where its at) compatibility built into it, but a DBAPI would be the most direct way to get SQLAlchemy working with it.

So here's some MS-specific non-DBAPI example: http://www.ironpython.info/index.php/Accessing_SQL_Server someone talking about DBAPI in 2006: http://hex-dump.blogspot.com/2006/10/ironpython-and-adonet-part-2.html something a little more recent: http://bitbucket.org/jdhardy/adonet-dbapi/

It says something that MS pours however much money into IronPython but zero into a compliant DBAPI driver.

You could try using SQLAlchemy's adodbapi support instead; the latest version of adodbapi (2.3.0) supports IronPython.

You should only have to make sure the adodbapi package is on sys.path, and then use 'mssql+adodbapi://' instead of 'mssql://' in your connection string.

adodbapi seems the way to go, but here's a snippet from adodbapi.py that ships with SQL Alchemy under the dialects folder

"""
The adodbapi dialect is not implemented for 0.6 at this time.

"""

SQLAlchemy can not directly run under IronPython, because pyodbc currently is not compatible with IronPython.

However, you can use pypyodbc under IronPython as a dbi-2.0 complaint library, which is similar to pyodbc,and enables running sqlalchemy under Ironpython, this How-to describes the 4 steps to enable it.

Disclaimer: I'm the maintianer of pypyodbc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!