txt3rob
Posts: 365
Joined: Sat Aug 11, 2012 3:45 pm
Contact: Website

mysql and var

Tue Aug 27, 2013 9:10 pm

I have the following i am struggling with i'm not amazing with python.

Any one ideas i hear it's due to a tuple but not got a clue what that is haha!

Code: Select all

#Grab the SMS  to Tweet Contents
cursor.execute ("SELECT * FROM `twitter` WHERE `content` IS NOT NULL AND `messagesent` = 0 LIMIT 1")
# fetch all of the rows from the query
data = cursor.fetchall ()
for row in data :
	sql = "UPDATE `texts`  SET `messagesent` = 1 WHERE id = %s", row[id]
       cursor.execute	(sql)
The Raspberry Pi Hell Guy - Random Ramblings to assist me and others.
http://raspberrypihell.blogspot.com
My Github - http:/www.github.com/random-robbie/
http://www.smspi.co.uk - send free uk sms via your raspberry pi from here

karl101
Posts: 68
Joined: Wed Jan 11, 2012 10:09 am

Re: mysql and var

Sun Sep 01, 2013 9:45 am

assuming you have created your cursor with something like:

Code: Select all

cursor = myDB.cursor(cursorclass=MySQLdb.cursors.DictCursor)
and your twitter table has an 'id' column? then try this:

Code: Select all

sql = "UPDATE `texts`  SET `messagesent` = 1 WHERE id = %s"
cursor.execute   (sql,(row['id']))
Karl.

txt3rob
Posts: 365
Joined: Sat Aug 11, 2012 3:45 pm
Contact: Website

Re: mysql and var

Mon Sep 02, 2013 7:55 am

cheers for the reply karl :)
The Raspberry Pi Hell Guy - Random Ramblings to assist me and others.
http://raspberrypihell.blogspot.com
My Github - http:/www.github.com/random-robbie/
http://www.smspi.co.uk - send free uk sms via your raspberry pi from here

Return to “Python”