> Aaargh, few hours after I decide that I run into this. From an intent
> perspective it is much more consistent with what I was looking for -
> http://www.pauldeden.com/2009/01/edendb-thin-flexible-and-fast-python.html
>
> The sample usage is listed here
> http://code.google.com/p/edendb/

web.db is more elegant than that.

>>> import web
>>> db = web.database(dbn='sqlite', db='test.db')
>>> db.query("create table people (name varchar(10), age integer, pet 
>>> varchar(10))")
0.0 (1): create table people (name varchar(10), age integer, pet varchar(10))
-1
>>> db.insert('people', name='paul', age=2, pet='cat')
0.0 (1): INSERT INTO people (pet, age, name) VALUES ('cat', 2, 'paul')
0.0 (2): SELECT last_insert_rowid();
1
>>> db.insert('people', name='tom', age=88, pet='dog')
0.0 (1): INSERT INTO people (pet, age, name) VALUES ('dog', 88, 'tom')
0.0 (2): SELECT last_insert_rowid();
2
>>> for r in db.select("people"): print r.name, r.age, r.pet
...
0.0 (1): SELECT * FROM people
paul 2 cat
tom 88 dog
>>> for r in db.select("people", where='age > $age', vars={"age": 50}): print 
>>> r.name, r.age, r.pet
...
0.0 (1): SELECT * FROM people WHERE age > 50
tom 88 dog

-Anand
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to