Database Programming with Python

F

Finger.Octopus

Hi

I wanted to connect Python to Ms-Access database using ADO or ODBC. I
have Python 2.5 and on mxODBC site, it has no higher version build
than 2.4. Moreoever, mxODBC is required for ADODB.
Can anyone guide me on this what should I do to make it work on Python
2.5? I have python 2.5 running on server.
 
F

fumanchu

I wanted to connect Python to Ms-Access database using ADO or ODBC. I
have Python 2.5 and on mxODBC site, it has no higher version build
than 2.4. Moreoever, mxODBC is required for ADODB.
Can anyone guide me on this what should I do to make it work on Python
2.5? I have python 2.5 running on server.

You could use Dejavu 1.5, which has its own wrapper [1] for ADO (both
MS Access and SQL Server/MSDE). No ODBC necessary or desired.

If you want an ADO wrapper without the full Dejavu ORM, it's possible
(but not heavily documented) to use dejavu's geniusql layer on its
own. That would give you connection mgmt (and pooling), along with the
ability to execute arbitrary SQL.


Robert Brewer
System Architect
Amor Ministries
(e-mail address removed)

[1] http://projects.amor.org/dejavu/browser/trunk/storage/storeado.py
 
F

Finger.Octopus

You could use Dejavu 1.5, which has its own wrapper [1] for ADO (both
MS Access and SQL Server/MSDE). No ODBC necessary or desired.

If you want an ADO wrapper without the full Dejavu ORM, it's possible
(but not heavily documented) to use dejavu's geniusql layer on its
own. That would give you connection mgmt (and pooling), along with the
ability to execute arbitrary SQL.

Robert Brewer
System Architect
Amor Ministries
(e-mail address removed)

[1]http://projects.amor.org/dejavu/browser/trunk/storage/storeado.py


There are no examples of Dejavu that I found yet. I have installed it
but don't know how to use or call its functions.
 
T

Tim Roberts

I wanted to connect Python to Ms-Access database using ADO or ODBC. I
have Python 2.5 and on mxODBC site, it has no higher version build
than 2.4. Moreoever, mxODBC is required for ADODB.
Can anyone guide me on this what should I do to make it work on Python
2.5? I have python 2.5 running on server.

You don't actually need mxODBC to use ADODB. As long as you have the
pywin32 extensions, you have what you need.

import win32com.client
conn = win32com.client.Dispatch('ADODB.Connection')
conn.Open( "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=xxxxx.mdb" )
cmd = win32com.client.Dispatch('ADODB.Command')
cmd.ActiveConnection = conn

cmd.CommandText = "SELECT firstname,lastname FROM users;"
rs = cmd.Execute()[0]
while not rs.EOF:
# Use elements of rs
rs.MoveNext()

There are samples on the web. Google should help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top