Greetings,
If I enter the following string into the standard mysql client:
create database python_testing;use python_testing;create table test (test char(60) binary not null default '');
It runs fine. If I try to run it using MySQLdb, I get the following error:
(1064, "You have an error in your SQL syntax near ';use python_testing;create table test (test char(60) binary not null default '')' at line 1")
Here is my code (I have replaced sensitive info with 'xx'):
import MySQLdb create_sql = """create database python_testing;use python_testing;create table test (test char(60) binary not null default '');"""
conn = MySQLdb.connect(host="xx.xx.xx.xx",user="xxx",passwd="xxx") cursor = conn.cursor() cursor.execute(create_sql)
help?
You cannot issue multiple queries at once. Break it into multiple queries and remove the ';'.
(There IS a way to do it IF you have MySQL-4.1 and you set MySQLdb.constants.CLIENT.MULTI_STATEMENTS, but you should not normally do this.)
Ah. Thanks very much for your reply. Multiple queries it is.
thanks again :)
Log in to post a comment.
Greetings,
If I enter the following string into the standard mysql client:
create database python_testing;use python_testing;create table test (test char(60) binary not null default '');
It runs fine. If I try to run it using MySQLdb, I get the following error:
(1064, "You have an error in your SQL syntax near ';use python_testing;create table test (test char(60) binary not null default '')' at line 1")
Here is my code (I have replaced sensitive info with 'xx'):
import MySQLdb
create_sql = """create database python_testing;use python_testing;create table test (test char(60) binary not null default '');"""
conn = MySQLdb.connect(host="xx.xx.xx.xx",user="xxx",passwd="xxx")
cursor = conn.cursor()
cursor.execute(create_sql)
help?
You cannot issue multiple queries at once. Break it into multiple queries and remove the ';'.
(There IS a way to do it IF you have MySQL-4.1 and you set MySQLdb.constants.CLIENT.MULTI_STATEMENTS, but you should not normally do this.)
Ah. Thanks very much for your reply. Multiple queries it is.
thanks again :)