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?