[Zope-DB] Getting a cursor?
pw_lists at slinkp.com
Thu Sep 28 11:30:15 EDT 2006
On Thu, Sep 28, 2006 at 11:20:13AM +0200, Charlie Clark wrote:
> Am 28.09.2006, 00:26 Uhr, schrieb Paul Winkler <pw_lists at slinkp.com>:
> >I'll be writing product code, and am currently just experimenting via
> >zopectl debug, so I have full access to everything. But I still can't
> >see how to get a cursor or anything else that will let me retrieve
> >multiple record sets from one STP call.
> >What should I be looking for?
> >./bin/zopectl debug
> >Starting debugger (the name "app" is bound to the top-level Zope object)
> >>>>conn = app.sweetums_test()
> ><Products.mxODBCZopeDA.ZopeDA.DatabaseConnection "DSN=MSSQLdsn" thread
> >47227742061040/47227742061040 at 0x2aaaab0907e8>
> You don't need an explicit cursor as you already have one for your
> connection. Simply use callproc()
> conn.callproc(procedure_name, params)
> while True:
> rset = conn.fetchone()
No dice, it barfs on that line:
Traceback (most recent call last):
File "<stdin>", line 2, in ?
AttributeError: DatabaseConnection instance has no attribute 'fetchone'
And, as I pointed out in my original post, DatabaseConnection.callproc()
has a different API from cursor.callproc(). Per my experimentation,
cursor.callproc() gets (but does not return) all result sets, which can
then be accessed via cursor.fetchone(), cursor.nextset() etc.
But DatabaseConnection.callproc() simply returns either the first or
last result set, depending on your configuration. All other result sets
Thanks for the help though. Any other suggestions?
More information about the Zope-DB