[Tutor] Need help with sqlite3 in python

Jim Byrnes jf_byrnes at comcast.net
Sun Feb 17 17:50:11 CET 2013

I am writing a small database CRUD app using python 2.7, pythoncard, 
sqlite3 on Ubuntu 12.04.  So far I can retrieve data fine but I cannot 
do inserts. In my first attempt I used parameter substitution. When that 
did not work I thought I didn't understand it and decided to try a 
simple insert.  I modeled the code after the example on the python 
sqlite3 page.  Here is the code that does not work.  Note: Don't mind 
the title, the delete button had no code yet and seemed to be the 
easiest place to run this simple test.

def on_buttonDelete_mouseClick(self, event):
	conn = sqlite3.connect("/home/jfb/MyProgs/Pwds/passwords")
	cur = conn.cursor()
	cur.execute("INSERT INTO pwds VALUES ('WebSites', 'xMe', 'me', 'you', 
'here', 'there')")
	print 'done'

When this code is run, done prints in the terminal, there is no error 
message, the row is not inserted and the file modified time is not 
changed.  The permissions set on the file are -rw -rw -rw. Sqlite3 is 
imported and if I mangle the path or execute line it complains. If I run 
the same sql in Sqliteman the row is inserted as expected.

Appreciate it if someone could give me an idea of what I am doing wrong.

Thanks,  Jim

More information about the Tutor mailing list