1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #!/usr/bin/python
import MySQLdb
db = MySQLdb.connect("localhost","root","pass","test" )
cursor = db.cursor()
# Prepare SQL query to INSERT a record into the database.
sql = "SELECT * FROM client_table"
try:
# Execute the SQL command
cursor.execute(sql)
# Fetch all the rows in a list of lists.
results = cursor.fetchall()
for row in results:
idclient = row[0]
photo= row[14]
sql2 = "UPDATE g_client SET data_img='%f' WHERE idca='%f'" % (photo,idclient)
cursor.execute(sql2)
db.commit()
except:
print "Error: unable to fecth data"
raw_input("une touche pour Fermer ..............")
# disconnect from server
db.close() |