I've developed a little module that makes it really easy to plug in .sql files into a python product class as ZSQLMethods. It's extremely easy to use and doesn't require any CMF or ZODB stuff. It also has support for memcache for those of you with slow db queries that you need to repeat.

It works something like this::

 from Products.ZSQL import initializeSQLfiles
 class _SQLBase(Acquisition.Implicit):
    dbConnection = 'Psycopg_database_connection'
 class SQLUser(_SQLBase):
 folders2classes = {'sql/Userstuff': SQLUser}
 home = package_home(globals())
 initializeSQLfiles(folders2classes, home)

If in the folder 'sql/Userstuff' you have a file called 'select_users.sql' you will the be able to just run:

 # select users:
 print SQLUser.select_users()
 # same but first printed the final SQL used
 print SQLUser.select_users(debug__=True)
 # save time for the next call
 print SQLUser.select_users(memcache__=True)

Is anybody interested in a being early beta testers before I release it as Open Source? It works quite well here for me but I fear I'm getitng a bit home blind based on just my needs. I'm pretty sure it works but some early feedback would be appreciated.


Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to