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): pass 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 -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
It works something like this:: (...) 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) Few questions :) sql/Userstuff is a filesystem folder or a folder in ZODB?
How does select_users.sql look? is this dtml with parameters like in ZSQLMethods? Can I just pass parameters like: SQLUser.select_users(param1='p1', param2='p2')? Have you compared zsql + memcache performace with eg. CCZSQLMethods from Dieter Maurer?
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. I'm interested, although I can't guarantee quick response :)
-- Maciej Wisniowski
Maciej Wisniowski wrote:
It works something like this:: (...) 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) Few questions :) sql/Userstuff is a filesystem folder or a folder in ZODB?
On the filesystem. No ZODB.
How does select_users.sql look? is this dtml with parameters like in ZSQLMethods? Can I just pass parameters like: SQLUser.select_users(param1='p1', param2='p2')?
Exactly like DTML ZSQLMethods. Yes.
Have you compared zsql + memcache performace with eg. CCZSQLMethods from Dieter Maurer?
Wasn't aware of this project. Will check it out.
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. I'm interested, although I can't guarantee quick response :)
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (2)
-
Maciej Wisniowski -
Peter Bengtsson