[Zope-DB] Getting a cursor?

Charlie Clark charlie at egenix.com
Thu Sep 28 05:20:13 EDT 2006


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)
> (snip)
>>>> conn = app.sweetums_test()
>>>> conn
> <Products.mxODBCZopeDA.ZopeDA.DatabaseConnection "DSN=MSSQLdsn" thread
> 47227742061040/47227742061040 at 0x2aaaab0907e8>
>>>> dir(conn)

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()
     pprint.pprint(rset)
     print "============================="
     if conn.nextset() is None: break

Charlie


More information about the Zope-DB mailing list