PyADO

hosted by SourceForge.net Logo

Description

PyADO is a Python DB-API 2.0 compliant interface to Microsoft's ActiveX Data Objects.

This allows a connection to any OLE DB driver/database using standard DB-API code.

PyADO is written entirely in Python, and uses the Python for Windows extensions to interface with COM.

Although it is also possible to use ADO directly from Python, with the Windows extensions, this driver allows code written to use DB-API 2.0 to use ADO, which means that this code will be portable to other Python database drivers.

The source code is licensed under the Python license (Python Software Foundation version).

Related projects

Sourceforge Links

PyADO is hosted by SourceForge. Here are the various relevant pages...

There are three mailing lists for PyADO. Please use the appropriate one for any questions.

Contributors

PyADO was created by David Fraser and Shayan Raghavjee of St James Software.

Any additional contributions are welcome, and will be listed here. Please use the mailing lists or contact the project admin (David Fraser) through the project page.

News

2002-08-20: The project has been created and release 0.1 is available for download...

2002-08-20: The project is being created...

Status

PyADO and DB-API 2.0 requirements:

PyADO has been used successfully on:

If you have any problems on a different system, or get PyADO working, please let us know

Quick Start and Sample Code:

This assumes you have ADO and the database installed. Download and install the following:

Then download PyADO from the downloads page above. Assuming you installed Python into C:\Python22, a good place to put the PyADO.py module so its always available is in C:\Python22\Lib\site-packages.

Test the installation: Run Python and try and import the module:

import PyADO

Try connect to a database:

conn = PyADO.connect(None,user='admin',password='',host=None,database='C:\\test.mdb',provider='Microsoft.Jet.OLEDB.4.0')

This example connects to an Access database in C:\test.mdb. Note that host should be set to None unless you are using SQL Server... Also note that you need to pass the OLE DB provider name as a parameter to connect

Now you need a cursor to execute statements on:

curs = conn.cursor()

Now let's run a SQL statement (you will need to put a useful statement here):

curs.execute("select * from some_table")

Finally let's display the data

result = curs.fetchall()
descr = curs.description
for col in descr:
    print col[0],
print
for row in result:
    for col in row:
        print col,
    print

You can disconnect as well:

curs.close()
conn.close()