Excel database module

Cy Edmunds cedmunds at spamless.rochester.rr.com
Mon May 10 19:24:52 EDT 2004


"Garret McGraw" <garret_mcgraw at yahoo.com> wrote in message
news:mailman.382.1084143082.25742.python-list at python.org...
> Has anybody heard of or know of a python module for
> reading/parsing/writing microsoft excel databases?
> Any response would be greatly appreciated.
>
> Thanks,
> GEM
>

If  you really mean "database" you can do whatever you like using odbc. Fire
up your Data Sources program (under Control Panel/Administrative Tools in
XP) and do an Add/Microsoft Excel Driver. You will have to browse for the
Excel file and give the connection a name. Let's say you pick "Melvin". Then
in Python:

import odbc
import dbi
dbc = odbc.odbc("Melvin")
crsr = dbc.cursor()
sql = "select foo from bar;"
crsr.execute(sql)
print crsr.fetchone()
dbc.close()

"bar" is a named range in the workbook which contains column headings, one
of which is "foo". If it looks like:

foo  baz  bref
2  3  5
7  9  1

your program will print out:

(2,)

How well does all this work in practice? No idea. I just tried it for the
first time and all I can say is it worked OK for my trivial example.

-- 
Cy
http://home.rochester.rr.com/cyhome/





More information about the Python-list mailing list