[DB-SIG] Re: DB-SIG digest, Vol 1 #530 - 1 msg

Matthew Vranicar vranicar@fnal.gov
Thu, 13 Dec 2001 11:16:18 -0600


If that did not work, the only other thing you can try before you will have
to debug the source is to use different cursor names for each execution.
I do not think that will help either, but it may be worth a try.


import DB2
conn = DB2Connection(dsn='xxx', uid='xxx', pwd='xxx')

# 1
cur1 = conn.cursor()
ret = cur1.execute("SELECT * from TABLE")
data = cur1.fetchall()
cur1.close()

# 2
cur2 = conn.cursor()
ret = cur2.execute("SELECT * from TABLE WHERE ID LIKE 'abc%'")
data = cur2.fetchall()
cur2.close()

# 3
cur3 = conn.cursor()
ret = cur3.execute("SELECT ID, NAME from TABLE")
data = cur3.fetchall()
cur3.close()


"Coulter, Cary" wrote:

> No change.
>
> -----Original Message-----
> From: Matthew Vranicar [mailto:vranicar@fnal.gov]
> Sent: Thursday, December 06, 2001 10:13 AM
> To: db-sig@python.org; Coulter, Cary
> Subject: Re: DB-SIG digest, Vol 1 #530 - 1 msg
>
> Cary,
> What if you did not just reuse the same cursor, but used individual
> cursor
> objects for each of your queries?  Or at least closed/opened the cursor
> again.  Would this help?
>
> Like this:
>
> import DB2
> conn = DB2Connection(dsn='xxx', uid='xxx', pwd='xxx')
>
> # 1
> curs = conn.cursor()
> ret = curs.execute("SELECT * from TABLE")
> data = curs.fetchall()
> curs.close()
>
> # 2
> curs = conn.cursor()
> ret = curs.execute("SELECT * from TABLE WHERE ID LIKE 'abc%'")
> data = curs.fetchall()
> curs.close()
>
> # 3
> curs = conn.cursor()
> ret = curs.execute("SELECT ID, NAME from TABLE")
> data = curs.fetchall()
> curs.close()
>
> db-sig-request@python.org wrote:
>
> > Send DB-SIG mailing list submissions to
> >         db-sig@python.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         http://mail.python.org/mailman/listinfo/db-sig
> > or, via email, send a message with subject or body 'help' to
> >         db-sig-request@python.org
> >
> > You can reach the person managing the list at
> >         db-sig-admin@python.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of DB-SIG digest..."
> >
> >
> ------------------------------------------------------------------------
> > Today's Topics:
> >
> >    1. IBM DB2 interface module DB2.py (Coulter, Cary)
> >
> >
> ------------------------------------------------------------------------
> >
> > Subject: [DB-SIG] IBM DB2 interface module DB2.py
> > Date: Mon, 3 Dec 2001 13:27:44 -0600
> > From: "Coulter, Cary" <Cary.Coulter@argushealth.com>
> > To: <db-sig@python.org>
> >
> > I'm running DB2 on AIX.  Using the DB2.py (v0.99) module. I'm able to
> > fetch some data but am having a problem.
> >
> > Sample code:
> >
> > import DB2
> >
> > conn = DB2Connection(dsn='xxx', uid='xxx', pwd='xxx')
> >
> > curs = conn.cursor()
> >
> > # 1
> > ret = curs.execute("SELECT * from TABLE")
> > data = curs.fetchall()
> >
> > # 2
> > ret = curs.execute("SELECT * from TABLE WHERE ID LIKE 'abc%'")
> > data = curs.fetchall()
> >
> > # 3
> > ret = curs.execute("SELECT ID, NAME from TABLE")
> > data = curs.fetchall()
> >
> > The first 2 select/fetchall's work.  'data' is a list of tuples
> > containing the row data.  Dumping curs.description shows a tuple of
> > tuples with all of the columns and their attributes.
> >
> > The third execute/fetchall doesn't work completely.  'data' is a empty
> > list ([] rather than None) but curs.description contains a tuple of
> > tuples for the 2 columns specified.
> >
> > Any idea why #3 won't work or something to look at??  I can put some
> > debug code in the _db2_module.c code and log stuff to disk, but first
> > I'm looking for something simpler than learning the low level
> interface
> > to DB2.
> >
> > Thanks in advance.
> >
> > Cary Coulter
> > Lead System Programmer
> > 816-435-2425
> > Argus Health Systems, Inc.