pymysql concurrent connections

589 views
Skip to first unread message

Csaba Ragany

unread,
Apr 8, 2015, 12:36:47 PM4/8/15
to pymysq...@googlegroups.com
Dear All,

How is it possible to make a MySQL connection that will not lock the DB? I have a Python script that can be run multiply at once. And when the first run of the python script makes a connection than the second run will fail because the first run still has an active connection.

My python script looks like this:

import pymysql

connection = pymysql.connect(host=__host, port=__port, user=__user, passwd=__password, db=__db_name, charset=__charset)

cursor = connection.cursor()

cursor.execute("SELECT max(ID) FROM <my_table>;")

ret = cursor.fetchall()

cursor.close()

connection.close()


Thanks for help!

INADA Naoki

unread,
Apr 8, 2015, 1:11:37 PM4/8/15
to pymysq...@googlegroups.com
What is your exact error?
MySQL and PyMySQL supports concurrent connection and query.



--
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>

Patrick Dunnigan

unread,
Apr 8, 2015, 1:30:49 PM4/8/15
to pymysq...@googlegroups.com
This is not a symptom of multiple connection, or multiple connections from pymysql. You are probably experiencing a table lock issue.

in fact my guess would be that if you opened two mysql workbenches and ran the query at the same time it would happen there.

Do you have a specific error message?

If it is indeed a table lock, google "mysql read uncommitted"



April 8, 2015 at 12:36 PM
Reply all
Reply to author
Forward
0 new messages