mxODBC module

Daley, MarkX markx.daley at intel.com
Thu Jul 6 11:05:24 EDT 2000


I'm using mxODBC and mxDateTime, but I don't import parts of it, I import
the whole thing and use it from there.  Here is an example:

import dbi, odbc

<snip>

dbc = odbc.odbc(index+'/username/password')
crsr = dbc.cursor()
for name in familyname:
	double = []
	crsr.execute("""select * from subtestlist\n\
where (errorcode<>'null'\n\
AND familyname='"""+name+"""'\n\
AND Packagestarttime>'"""+sql_date+"""'\n\
AND Packagestarttime<='"""+current_date+"""');""")
result = crsr.fetchall()

This allows me to retrieve all data associated with the selected familyname
and put it in result.  I then unpack, format and write the data to a text
file.  This works for me, but you might want to look at
http://www.python.org/windows/OdbcHints.html
Everything I understand about ODBC I took from there.

HTH

- Mark

-----Original Message-----
From: ekw1 at my-deja.com [mailto:ekw1 at my-deja.com]
Sent: Wednesday, July 05, 2000 10:21 PM
To: python-list at python.org
Subject: mxODBC module


I've installed mxODBC along with mxDateTime for Python 1.5.2 on
Windows98.  I'm getting errors when I try to connect to a MySQL 3.23.19
database (which I've used MyODBC to set up ODBC connection to it).

When I try to use ODBC.Windows, I get this error:
>>> import ODBC.Windows
>>> db = ODBC.Windows.Connect("DSN_name")
Traceback (innermost last):
  File "<pyshell#15>", line 1, in ?
    db = ODBC.Windows.Connect("PyNotes")
NotSupportedError: ('S1C00', 0, "[TCX][MyODBC]MySQL can't use
transactions", 4226)

And I can't even import ODBC.MySQL:
>>> import ODBC.MySQL
Traceback (innermost last):
  File "<pyshell#13>", line 1, in ?
    import ODBC.MySQL
  File "C:\Program Files\Python\Lib\ODBC\MySQL\__init__.py", line 7, in
?
    from mxODBC import *
ImportError: No module named mxODBC

mxODBC is on the same directory level as MySQL, but it can't be found.

I don't know what the differences/advantages to either method would be,
but can anyone help me get this working?  I am able to connect to the
MySQL DB via Java and JDBC-ODBC and program it successfully, but would
like to get Python connected as well.  Thanks for any help.

ekw


Sent via Deja.com http://www.deja.com/
Before you buy.





More information about the Python-list mailing list