Trouble with SQLite and update

This is the place for queries that don't fit in any of the other categories.

Trouble with SQLite and update

Postby mickpc » Thu Jul 31, 2014 5:25 am

I have the following code:

Code: Select all
#!/usr/bin/python

import sqlite3

conn = sqlite3.connect('data.db')
print "Opened database successfully";

conn.execute("UPDATE NUMDATA set VALUE = 3.0 where ID=2")
conn.commit
print "Total number of rows updated :", conn.total_changes

cursor = conn.execute("SELECT id, time, value  from NUMDATA")
for row in cursor:
   print "ID = ", row[0]
   print "TIME = ", row[1]
   print "VALUE = ", row[2], "\n"

print "Operation done successfully";

conn.close()


Now it says it updates the database, and displays the change. But when I query it (from a seperate script), it shows no change.

Thankyou

Mick
Last edited by Yoriz on Thu Jul 31, 2014 5:43 am, edited 1 time in total.
Reason: First post lock.
mickpc
 
Posts: 1
Joined: Thu Jul 31, 2014 5:22 am

Re: Trouble with SQLite and update

Postby Yoriz » Thu Jul 31, 2014 5:43 am

Welcome to the forum, Please read the new users read this link in my signature.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Image
User avatar
Yoriz
 
Posts: 1170
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 4 guests