SQLAlchemy 0.2 released - a generic database adapter for Zope 2
I am pleased to announce the first public release of SQLAlchemyDA V 0.2.0 Download: --------- <http://opensource.zopyx.com/software/sqlalchemyda/releases/0.2.0> What is SQLAlchemyDA? --------------------- SQLAlchemyDA is both a tiny frontend to the z3c.sqlalchemy SQLAlchemy package for Zope 2 and Zope 3. In addition it acts as a database adapter for ZSQL methods. Since it is based on SQLAlchemy, SQLAlchemy supports all databases out-of-the box that are supported by SQLAlchemy. Requirements: ------------- - Zope 2.8 + - SQLAlchemy 0.3.X - z3c.sqlalchemy 1.0.0 + Installation: ------------- - download and install z3c.sqlalchemy as egg or from the sources from Cheeseshop (easy_install z3c.sqlalchemy) - A z3c.sqlAlchemy SAWrapper must be registered. The best way to do this right now to put something like this into your Product's initialize(): Products/YourProduct/__init__.py: def initialize(context): from z3c.sqlalchemy import createSAWrapper, registerSAWrapper wrapper = createSAWrapper('postgres://user:password@host/database', forZope=True) registerSAWrapper(wrapper, 'my-sa-wrapper') - After restarting Zope you go to the ZMI and create an instance of "SQLAlchemy Wrapper Integration" (as you would create some DA instance). After creating the instance you should see 'my-sa-wrapper' in the properties form of the new instance. When creating a new ZSQL method you should be able to use this DA instance as connection id. Using SQLAlchemyDA: ------------------- - for using SQLAlchemyDA through object mappers as used in SQLAlchemy you can use the getMapper() and getMappers() methods. Check the z3c.sqlchemy documentation for details. A SQLAlchemy Session object can be obtained by the getSession() method. Sessions are integrated with Zope 2 transaction management. - a SQLAlchemyDA instance can be used as a standard DA together with ZSQL methods. WARNING: YOU SHOULD NOT USE ZSQL METHODS AND MAPPERS WITHIN THE SAME REQUEST!!! Mappers/Sessions and Connections (for ZSQL methods) are totally independent and have their own transaction. Mixing both would result in two distinct transactions leading to unpredictable results. License ======= SQLAlchemyDA is licensed under the Zope Public License 2.1. See LICENSE.txt. Andreas Jung -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535 Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK ------------------------------------------------------------------------ E-Publishing, Python, Zope & Plone development, Consulting
Andreas Jung schrieb:
I am pleased to announce the first public release of
SQLAlchemyDA V 0.2.0
Nice, saves me a lot of time :-) Btw, what do you think about an idea to (alternatively) configure db-connections in zope.conf? Just to add security (nobody could read credentials, nobody could connect to whatever host/port he wants) Regards Tino
--On 5. Mai 2007 20:58:39 +0200 Tino Wildenhain <tino@wildenhain.de> wrote:
Andreas Jung schrieb:
I am pleased to announce the first public release of
SQLAlchemyDA V 0.2.0
Nice, saves me a lot of time :-) Btw, what do you think about an idea to (alternatively) configure db-connections in zope.conf? Just to add security (nobody could read credentials, nobody could connect to whatever host/port he wants)
Huh? This is solely an application level problem. You can store your DSN wherever you want and pass it somehow to the createSAWrapper(..) method..totally out-of-scope of my implementation. Andreas
Tino Wildenhain wrote at 2007-5-5 20:58 +0200: ...
Btw, what do you think about an idea to (alternatively) configure db-connections in zope.conf?
I like local (instance specific) configurations -- that the primary reason while we have the instances at all. While local configurations are possible in "zope.conf", it is somewhat tedious (as can be seen for mount points). -- Dieter
+-------[ Andreas Jung ]---------------------- | | I am pleased to announce the first public release of | | SQLAlchemyDA V 0.2.0 Does this allow us to have "proper" connection pooling instead of simply having 1 connection per "DA" per configured worker thread as it is with "normal" DAs ? -- Andrew Milton akm@theinternet.com.au
--On 6. Mai 2007 05:59:57 +1000 Andrew Milton <akm@theinternet.com.au> wrote:
+-------[ Andreas Jung ]---------------------- | | I am pleased to announce the first public release of | | SQLAlchemyDA V 0.2.0
Does this allow us to have "proper" connection pooling instead of simply having 1 connection per "DA" per configured worker thread as it is with "normal" DAs ?
It uses the SQLAlchemy connection pool. Basically for each request one connection is taken from the pool and returned to the pool after completion. Andreas
participants (4)
-
Andreas Jung -
Andrew Milton -
Dieter Maurer -
Tino Wildenhain