July 10th, 2009
web.py tutorial + sqlite
Topics: Python, Web.py, HowtoIf you want to follow the web.py tutorial using sqlite here’s how:
Line for your python to connect to DB
db = web.database(dbn='sqlite', db='testdb')
To create the database type
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 your ready by typing
.quit