1

In the following code:

print(str(processedEmails))
print(campaignId)

returns values I was expecting.

What I'm trying to do (why I ran print() statements to check):

cursor.execute('UPDATE campaigns SET campaign_finish_date = (NOW()) AND queue_size =' + str(processedEmails) + ' WHERE id=' + campaignId)

checking via phpMyAdmin:

NOW() = 0000-00-00 00:00:00.000000
campaignId = 0 (what I set as default)

Values not transferred.

What am I doing wrong?

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
brizz
  • 271
  • 1
  • 6
  • 17

1 Answers1

1

Assuming you're using MySQLdb module, you need to commit() the query if autocommit() is False (default).

See this.

Edit #1:

Then grant that the query is being successfully executed. Have you tried to execute that query via phpMyAdmin? Does it work as expected?

I've noticed that you've a AND instead a comma (',') on your update query:

You've this:

cursor.execute('UPDATE campaigns SET campaign_finish_date = (NOW()) AND queue_size =' + str(processedEmails) + ' WHERE id=' + campaignId)

Instead of this:

cursor.execute('UPDATE campaigns SET campaign_finish_date = (NOW()), queue_size =' + str(processedEmails) + ' WHERE id=' + campaignId)
Community
  • 1
  • 1
pah
  • 4,700
  • 6
  • 28
  • 37
  • Yea--ran into that problem early on, but I have the commit() in my code. Will edit my post to show [but yea...def issue among many people] – brizz May 05 '14 at 05:03
  • that fixed it. heh... syntax :\ ..thank you so much! – brizz May 05 '14 at 05:26