July 10th, 2009
web.py + SQLite tutorial
If you want to follow the web.py tutorial using SQLite here’s how:
The line for your Python to connect to DB:
db = web.database(dbn='sqlite', db='testdb')
sqlite3 testdb
and input this SQL:
CREATE TABLE todo (id integer primary key, title text, created date, done boolean default 'f');
CREATE TRIGGER insert_todo_created after insert on todo
begin
update todo set created = datetime('now')
where rowid = new.rowid;
end;
Now create an entry with this SQL
insert into todo (title) values ('Learn web.py');
Finally, quit sqlite3 when you’re ready by typing .quit