IT Ninja
IT Ninja

Reputation: 6430

python mysqldb multiple cursors for one connection

When you have one connection object, can you make multiple cursors to that one single connection and execute queries with these cursors at the same time? Or would each cursor wait for the previous cursor to finish its query?

connection type: database=MySQLdb.connect(...)
cursor:          curs=database.cursor()
querying:        curs.execute("query")

Upvotes: 31

Views: 23145

Answers (1)

bbenne10
bbenne10

Reputation: 1587

You'll need to open multiple connections. Mysqldb is threadsafe, so each connection will be able to access their respective cursors, queries and result sets without having an effect on the other connections but each thread or process will need its own connection.

Upvotes: 33

Related Questions