My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 102: Strange pyodbc.ProgrammingError
1 person starred this issue and may be notified of changes. Back to list
Status:  NoFix
Owner:  ----
Closed:  Aug 2010


 
Reported by sectyst...@gmail.com, Jun 6, 2010
Hello, 

I get a problem during a query on MySQL 5.0.

This is what i'm trying to do:

Connecting to MySQL.. Everything is Ok!

cursor.execute("insert into ? (test) values ('test')", 'connection')
cnxn.commit()

So, it seems that the table name (?) have to be changed with connection.
But unfortunately this is what i get:

C:\>python mysqlC.py asd asd 1
Traceback (most recent call last):
  File "test.py", line 998, in <module>
    cursor.execute("insert into ? (test) values ('test')", 'connection')
pyodbc.ProgrammingError: ('42000', "[42000] [MySQL][ODBC 5.1
Driver][mysqld-5.0.
67-community-nt]You have an error in your SQL syntax; check the manual that
corr
esponds to your MySQL server version for the right syntax to use near
'_latin1'connection' (test) values ('test')' at line 1 (1064)
(SQLExecDirectW)")

Why?
Aug 20, 2010
Project Member #1 mkleehammer
I pass the query directly to the ODBC driver.  Apparently the MySQL driver doesn't support passing the table name as a parameter.  (I don't know of any drivers that do.)

You'll have to manually build the SQL to change the table.  I would still use question marks for actual parameters, though -- it avoids SQL injection attacks.

Status: Invalid
Nov 21, 2010
Project Member #2 mkleehammer
(No comment was entered for this change.)
Status: NoFix

Powered by Google Project Hosting