[Tutor] Fwd: Parameterized Queries failing on MySQL

Shea Grove goodpotatoes at yahoo.com
Wed Dec 15 23:58:02 CET 2010


> 

> I’m using pyodbc to interact with MS SQL Server and I’m starting to support mysql.  My issue is that when I use a parameterized query, it works for SQL Server, but crashes when I point to MySQL.  Is there a different syntax that I should be using? or module?
>  
> EG
> Import pyodbc
>  
> def openCursor(DSN):
>     cnxn=pyodbc.connect(('DSN=%s')%DSN)
>     cursor=cnxn.cursor()
>     return cnxn,cursor
>  
> lParams=[<list of parameters excracted from file>]
> query='insert into RestaurantTable values (?, ?, ?, ?, ?, ?, ?, ?, ?)'
>  
> #SQL Server Works
> scnxn,scursor = openCursor(SQLServer)
> scursor.execute(query,lParams)
> scnxn.commit()
> scnxn.close()
>  
> #This Query bombs out and crashes my IDLE shell.  No transactions are commited.
> mcnxn,mcursor = openCursor(MySQL)
> mcursor.execute(query,params)
> mcnxn.commit()
> mcnxn.close()
>  
>  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101215/6799c5d1/attachment.html>


More information about the Tutor mailing list