MySQL Forums
Forum List  »  Connector/Python

refresh connection using MySQLdb
Posted by: b cook
Date: January 08, 2007 05:51PM

i am accessing a shared server using MySQLdb module in python. however, if the database gets updated from a different source, after i have retrieved the data once, i do not get the updated version through python (even though i can see the data has been updated using a terminal). how do I refresh a connection?

pseudocode:
 
import MySQLdb
from MySQLdb.constants import CLIENT
conn=MySQLdb(host='192.168.0.100', user='jim', pw='tty554E', db='inventory', client_flag=CLIENT.MULTI.STATMENTS)
curs=conn.cursor()
curs.execute('call getinv(currentitem)')
res=curs.fetchall()
while curs.nextset() !=None:
   pass
.
.
.
# try again after db has been updated
curs.execute('call getinv(currentitem)')
res=curs.fetchall()
while curs.nextset() !=None:
   pass
if some inventory data retrieved by the getinv() procedure has changed between the two executions, i want to be able to retrieve the current data; however MySQLdb does not seem to refresh the connection data for the currentitem if it has retrieved it previously. closing the connection and reconnecting is the only way i have found to refresh teh connection, but this seems cumbersome.
i would like to be able to do something like:
 curs.refresh() 
but need a real command...
can anyone help please?

Options: ReplyQuote


Subject
Written By
Posted
refresh connection using MySQLdb
January 08, 2007 05:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.