[Zope-DB] DCOracle2 problem on Solaris 8

Matthew T. Kromer matt@zope.com
Wed, 17 Jul 2002 14:39:45 -0400


Tena Sakai wrote:

>Matt,
>
>Thank you!
>You hit the nail on its head.  The code below works.
>
>      #!/usr/local/bin/python
>
>      import DCOracle2
>      db = DCOracle2.connect('scott/tiger@glbl')
>      c = db.cursor()
>      c.execute("select * from scott.emp")
>      print c.fetchall()
>
>About a week or so ago, I had tried the import with DCOracle2
>and it complained as to it couldn't find DCOracle2.  I used find
>command in all lib directories for DCOracle2* and didn't find it.
>Then I tried with dco2 and that didn't complain.  But dco2.connect()
>didn't like 'scott/tiger@glbl' and it told me that it wanted 3 arguments.
>I gave what it asked, ie., "'scott', 'tiger', 'glbl'" and it stopped complain-
>ing.  And invocation of db.cursor() was done silently as well.  All this
>let me look over DCOracle2.
>
>Anyhow, your help is much appreciated.  I feel I am out of woods
>(famous last word?).
>
>  
>

Yes, what you were doing is hitting the C layer, which wants an 
(undocumented) optional integer argument, which is the COUNT of how many 
times to repeat the previously prepared() statement.  

You can get up to a 7 X performance increase by hitting the C layer 
directly, but that largely assumes that your application isn't looking 
at every cell in the result table.  (It is expensive to convert each 
cell into a python object).  The C layer has various quirks that the 
Python layer attempts to smooth over.  It actually IS fairly usable, but 
you have to deal with results differntly.

Here's an example, just FYI

import dco2

db = dco2.connect('scott','tiger','glbl')
c = db.cursor()

c.prepare('select * from emp')
c.execute()

rs = c.fetch(20)

for j in xrange(len(rs[0])):
    for i in xrange(len(rs)):
          print rs[i][j].value()

The downside is you have to do all of your parameter binding explicitly, 
etc.  Also, the result sets have a fixed maximum size (I think 200 
elements) and have to be accessed as resultset[column][row].value() to 
get a specific value.

-- 
Matt Kromer
Zope Corporation  http://www.zope.com/