mercredi 11 mars 2015

store sql result in a variable in python

I need help in storing the query result in a variable after executing the select statement. this is my code below.. there are no error but i need help in storing it in a variable in PYTHON. i am using pymssql and python 2.7.9. thanks in advance



conn = pymssql.connect(host='localhost', user='xx', password='xx', database='dbpython')
c = conn.cursor()
row = c.execute("select fid, fname, lname, contact from tblcontact where fname='maiji'")
row = c.fetchall()
while row:
print row
row = c.fetchall()

Aucun commentaire:

Enregistrer un commentaire