954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to move to the next record in MySQLdb?

how do i move to next record after i click a button called 'Next' and how do i move to previous record after i click 'Previous' in MySQLdb. does method exists to do this?

please help me...........

[I]import MySQLdb
from Tkinter import *

db=MySQLdb.connect(host='127.0.01',user='',passwd='',db='Trimtabs')
print 'mysql got connected.....'
cursor=db.cursor()

root=Tkinter.Tk()
e=Entry(root)
query="""select * from ticker"""
cursor.execute(query)
result=cursor.fetchall()

#value=StringVar()
#value.set(result[0])
print result
#e=Entry(root,textvariable=value)

def nextrec():

res=cursor.nextset()
#res=result[0]
#e.config(text='')
e.delete(0,10)
e.insert(0,res[0])
#pass

def previousrec():
#db.previous()
pass

b1=Button(root,text="Next",command=nextrec)
b2=Button(root,text="Previous",command=previousrec)
b1.pack()
b2.pack()

e.insert(1,result)
e.pack()
root.mainloop()

katharnakh
Posting Whiz in Training
237 posts since Jan 2006
Reputation Points: 19
Solved Threads: 34
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You