[Zope-DB] Basic tsql example using MxODBC Zope DA adaptor?

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Fri Jan 5 01:32:35 EST 2007

> I am relatively new to Zope/Plone, as well as the MxODBC Zope DA
> adaptor.  I am wondering if someone could point me to a basic example
> that would illustrate how to use the MxODBC Zope DA adaptor outside of
> a ZSQL method, using the Python API.  I am using a script to build
> transact-sql statements, and it doesn't appear to be possible to pass
> t-sql into a ZSQL method.
By default in Zope, when you call some SQL methods
during request, there is automatical commit or rollback
on your connection object at the end of request.
If there is any exception during request
rollback is called at DatabaseAdapter otherwise commit.

If it is not enough for you then you may try someting as
below, although I've not tried this with mxODBC, but this
may work. Get connection object like:

conn = context.mxODBCDatabaseConnection()

where 'mxODBCDatabaseConnection' is id of
your connection object in Zope.

execute query with:
conn.query('insert into table.... ')

finish transaction:

Maciej Wisniowski

More information about the Zope-DB mailing list