cursor.execute() does not support multiple/bulk insert queries

594 views
Skip to first unread message

Mythri Manjunath

unread,
Jan 10, 2018, 7:22:26 AM1/10/18
to PyMySQL Users
pymysql: cursor.execute() supports multiple query?
insert_statement= "INSERT INTO demo VALUES ('$SYS/publish/messages/received',0,1515580086025);
INSERT INTO demon VALUES ('$SYS/publish/messages/sent',0,1515580086025);
INSERT INTO demon VALUES ('$SYS/publish/messages/sent',3,1515580094997);
INSERT INTO demon VALUES ('$SYS/publish/messages/sent',4,1515580105983);"

cursor.execute(insert_statement):
when I try to execute,I get this
 error: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use

INADA Naoki

unread,
Jan 10, 2018, 7:36:37 AM1/10/18
to pymysq...@googlegroups.com
Yes, but you need to pass `client_flag=CLIENT.MULTI_STATEMENT` option
for pymysql.connect().
> --
> You received this message because you are subscribed to the Google Groups
> "PyMySQL Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pymysql-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
INADA Naoki <songof...@gmail.com>

Mythri Manjunath

unread,
Jan 10, 2018, 8:19:35 AM1/10/18
to PyMySQL Users
okay thanks a lot . will try with this flag. How many  statements would be supported ? 
MULTI_STATEMENTS = 1 << 16
Message has been deleted

INADA Naoki

unread,
Jan 10, 2018, 8:38:02 AM1/10/18
to pymysq...@googlegroups.com
I don't know.
It's up to MySQL.
I'm protocol expert, but I don't know much about MySQL or SQL.


2018/01/10 午後10:21 "Mythri Manjunath" <mythr...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages