IronPython db-api 2.0

2019-05-29 02:00发布

Does anyone know which if any db-api 2.0 drivers work with IronPython? If so, has anyone tried using it with SQLAlchemy, SQLObject or the Django ORM?

4条回答
姐就是有狂的资本
2楼-- · 2019-05-29 02:36

pypyodbc runs under IronPython and it's db-api 2.0 compliant. You can refer to this article to see how to enable SQLAlchemy under IronPython.

查看更多
对你真心纯属浪费
3楼-- · 2019-05-29 02:45

I have been able to get sqlalchemy working with MSSQL 2008 on ironpython 2.7 by following the steps here (with one change): [https://code.google.com/p/pypyodbc/wiki/Enable_SQLAlchemy_on_IronPython][1]

I had to change the last line below in step 4. removing all except pypyodbc

Step 4: Modify IronPython 2.7\Lib\site-packages\sqlalchemy\dialects\mssql__init__.py, in the top import line, add pypyodbc after mxodbc, like this:

#from sqlalchemy.dialects.mssql import base, pyodbc, adodbapi, \ 
                                       pymssql, zxjdbc, mxodbc, pypyodbc
from sqlalchemy.dialects.mssql import base, pypyodbc

Now you can use SQLAlchemy with below code:

import sqlalchemy
engine = sqlalchemy.create_engine('mssql+pypyodbc://MSSQL_DSN')
for row in engine.execute('select * from aTable'):
    print (row)
查看更多
霸刀☆藐视天下
4楼-- · 2019-05-29 02:54

I know this is a very late answer, but I only saw the question today -- so I am answering it today. http://sourceforge.net/projects/adodbapi contains a fully compliant db-api-2 module which works with IronPython. It is restricted to use in Windows, since it uses classic ADO, using COM calls, rather than ADO.NET. [I tried a true .NET version, but it worked very poorly. The fork for it is still there if anyone wants to follow up.] A fork of this module was adapted for a django extension for MS-SQL. I have pulled those adaptations back in to the main fork. I do not know whether anyone has tried using the result in django, yet, but it should work, provided one explicitly switches the paramstyle to "format".

import adodbapi as Database

Database.paramstyle = 'format'

查看更多
三岁会撩人
5楼-- · 2019-05-29 02:54

Here's some answers for sqlalchemy:

http://groups.google.com/group/sqlalchemy/browse_thread/thread/ea3ee246680c9d14?pli=1

At the end of the thread, someone tried a beta of IronPython in September last year and it was working.

Also here: SqlAlchemy discussion.

Support for jython, ironpython, others is much more of a drop-in as existing SQL compilation code can be reused.

查看更多
登录 后发表回答