[workshop] generic sql storage in python
Michal Wallace
workshop@cornerhost.com
Wed, 8 May 2002 16:02:33 -0400 (Eastern Daylight Time)
(crossposted to innnercircle and workshop lists)
I'll be covering this in detail in an upcoming
webAppWorkshop lesson, but if anyone's interested
you might want to check out the storage module:
http://cvs.sabren.com/sixthdev/cvsweb.cgi/storage/Storage.py?rev=1.1.1.1
http://cvs.sabren.com/sixthdev/cvsweb.cgi/storage/MySQLStorage.py?rev=1.1.1.1
Give it a database connection in the constructor,
it'll let you fetch and save individual records as
python dictionaries. The only requirement is that
you have a key named "ID"...
It's a fairly simple piece of code. Storage is the
generic case, MySQLStorage is for MySQL.
There's also a MockStorage which works like an in-memory
database (probably only useful for testing purposes):
http://cvs.sabren.com/sixthdev/cvsweb.cgi/storage/MockStorage.py?rev=1.1.1.1
Sincerely,
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: michal@sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.sabren.net/
--------------------------------------