June 29th, 2005, 12:28 PM
sqlite not creating table
cx = sqlite.connect("db")
cu = cx.cursor()
cu.execute('create table my_table(one varchar(200), two varchar(10))')
Im using the above code to create an sqlite database with a table caleld my_table.
The code runs fine, however the table my_table is not created. The code definitely runs, raises no exceptions and the db file is definitely not being created when attempting to insert something in a different part of the code.
Any ideas or help appreciated.
Both installed as standard with fedora core four, i also have the exact same problem on ubuntu 5.04.
June 29th, 2005, 03:28 PM
It's been a long time since I’ve used SQLite but you need to call the connection objects commit() method when you want to save changes to a database. I would call this just before closing the connection .
There is also an autocommit option that can be set at connection time (and an autocommit attribute) if this is more what you're looking for.
Hope this helps,
con = sqlite.connect('mydb', autocommit = True)
Comments on this post
June 30th, 2005, 07:44 AM
Its always the little things. I actually spent a whole day trying to figure that one out before giving up, even though i had done many times before.
Thanks, im going to go bang my head off a wall