mxODBC attribute error with MySQL

Keith MacDonald keith at nojunk.textpad.com
Wed Nov 8 05:21:41 EST 2000


Thanks Steve.

This helped put me on the right track.  The missing piece was the optional
connect parameter clear_auto_commit.  Without it, I was getting the
following arcane error message:

mxODBC.NotSupportedError: ('S1C00', 0, "[TCX][MyODBC]MySQL can't use
ransactions", 4226)

In case it helps anyone else, here is your example, modified for MySQL:

import ODBC.Windows
db = ODBC.Windows.connect('database',user='user',password='xyz',
clear_auto_commit=0)
cursor = db.cursor()
cursor.execute('select * from dataset')
resultSet = cursor.fetchall()
print resultSet
cursor.close()
db.close()

- Keith

"Steve Williams" <sandj.williams at gte.net> wrote in message
news:3A078D48.B45E4D92 at gte.net...
> Peter Hansen wrote:
>
> > Keith MacDonald wrote:
> > >
> > > I'm trying to use mxODBC 1.1.1 with MySQL and ActivePython 2.  The
only
> > > example I can find to get me started is in the mxODBC documentation,
but
> > > this is what I get when I try it:
> > >
> > > >>> import ODBC.MySQL
> > > >>> db = ODBC.MySQL.Connect('database','user','passwd')
> > > AttributeError: Connect
> > >
> > > (same error using "connect" as well)
> > >
> > > This is kind of unhelpful, as it gives me no idea what is wrong.  Can
anyone
> > > help me with this?
> >
>
> I don't know anything about MySQL, but the following works for DB2 and, I
think,
> Interbase:
>
>     import ODBC.Windows
>     . . .
>     connectionODS =
ODBC.Windows.Connect('ODS',user='gorgon',password='xyzzy')
>     cursorODS = connectionODS.cursor()
>     cursorODS.execute('select * from whatever')
>     resultSet = cursorODS.fetchall()
>     cursorODS.close()
>     connectionODS.close()
>
> resultSet is a two-dimensional list of  rows and then columns.
>
>
>





More information about the Python-list mailing list