Ann: pSQL.py (manipulation of SQL dbs through python objects)
fionn at spamfilter.de
Fri Oct 12 00:04:25 CEST 2001
Ian Bicking's announcement of SQLbuilder.py on the webware-discuss mailing
list a few days ago (very recommandable, btw; it includes a number of great
ideas) reminded me of the fact that I have something slightly similiar on disk
for quite some time now. I managed to motivate myself to write a readme and
prop up a web page for anyone who might be interested.
You can find it at: http://rtfm.n3.net/software/psql/
* Are you using a (My)SQL database all day in your programming projects
and dont want to write SQL statements again and again all over?
* Would you like to use an SQL database in your project without needing to
know much about SQL?
* Interested in making your database access sources a bit more readable
and easier to grok for other programmers?
If you can answer YES to one of these, pSQL might be of interest to you.
WHAT IT DOES:
Basically, pSQL wraps all database access and all data you get from your
database into some easy-to-handle and easily usable objects that "feel" like
standard python data structures. So, if you have a pSQL database object called
"myDB" with a table called Address, you can find all people in that table who
are living in Oklahoma by issuing a command like:
|>>> res = myDB.Address.City["Oklahoma%"]
To find out the phone numbers of those two,
you can use e.g.:
|>>> for r in res:
|... print "%s: %s"%(r.Name, r.Phone)
|John Doe: 0405-12345
|Joe User: 0405-67890
To change one of those numbers in the database:
|>>> john = res
|>>> john.Phone = '0405-54321' # or: res["Phone"] = '0405-54321'
WHAT IT DOES NOT:
pSQL currently works with MySQLdb only. This will change in a future version
and an abstraction layer will be added which allows the use of any DB 2.0 API
compliant SQL module, e.g. for postgres.
Visit the web page for more information.
More information about the Python-list