What's the simplest way to access mssql with python or ironpython?

前端 未结 8 2055
忘了有多久
忘了有多久 2020-12-04 16:56

I\'ve got mssql 2005 running on my personal computer with a database I\'d like to run some python scripts on. I\'m looking for a way to do some really simple access on the d

8条回答
  •  一整个雨季
    2020-12-04 17:40

    PyPyODBC (http://code.google.com/p/pypyodbc) works under PyPy, Ironpython and CPython.

    This article shows a Hello World sample of accessing mssql in Python.

    PyPyODBC has almostly same usage as pyodbc, as it can been seen as a re-implemenation of the pyodbc moudle. Because it's written in pure Python, it can also run on IronPython and PyPy.

    Actually, when switch to pypyodbc in your existing script, you can do this:

    #import pyodbc               <-- Comment out the original pyodbc importing line
    
    import pypyodbc as pyodbc    # Let pypyodbc "pretend" the pyodbc
    
    pyodbc.connect(...)          # pypyodbc has 99% same APIs as pyodbc
    
    ...
    

提交回复
热议问题