Reputation: 710
I'd like to make an python application and retrieve query results from mysql server.
So every time when an event happened, the application connect to mysql through mysqlclient like below
# retrieve query result from db
db=_mysql.connect(host="localhost",user="root",
passwd="password",db="db")
Is there a way not to try to connect every time but keep the connection?
Upvotes: 0
Views: 56
Reputation: 825
Change
begin loop:
get MQ msg
db=_mysql.connect(host="localhost",user="root",
passwd="password",db="db")
db.insert()
to
db=_mysql.connect(host="localhost",user="root",
passwd="password",db="db")
begin loop:
get MQ msg
db.insert()
Upvotes: 1