I'm going through the web.py 0.3 tutorials and once I get here I import sqlite3 and set dbn='sqlite3' but it won't work. Has anyone done this before?
Edit - I figured it out. I used the code in the link posted by John and made the following script:
import sqlite3
conn = sqlite3.connect('c:\users\user\py\database')
c = conn.cursor()
c.execute('''
CREATE TABLE todo (id integer primary key, title text, created date, done boolean default 'f');
''')
c.execute('''
CREATE TRIGGER insert_todo_created after insert on todo
begin
update todo set created = datetime('now')
where rowid = new.rowid;
end;
''')
c.execute('''
insert into todo (title) values ('Learn web.py');
''')
conn.commit()
c.close()
asked Feb 20, 2011 at 6:01
CamelCaseGuy
2911 gold badge4 silver badges9 bronze badges
-
What OS are you on? if not on Windows or Mac, what Linux distribution is it? Furthermore, is it python 2.5 or higher? Even if it is 2.5 or higher, if you don't compile your python with sqlite3 support, you won't have it.Crast– Crast2011年02月20日 06:08:33 +00:00Commented Feb 20, 2011 at 6:08
-
It's 2.7 32-bit and I'm on Windows 7. Also I got it to work with Django, so I'm pretty sure I have it.CamelCaseGuy– CamelCaseGuy2011年02月20日 06:31:18 +00:00Commented Feb 20, 2011 at 6:31
2 Answers 2
Shouldn't it be just dbn='sqlite'?
answered Feb 20, 2011 at 6:09
Ivan
31.4k6 gold badges26 silver badges21 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Google is your friend. Look at this.
answered Feb 20, 2011 at 6:13
John Machin
83.3k12 gold badges147 silver badges193 bronze badges
Comments
Explore related questions
See similar questions with these tags.
default