[DB-SIG] Re: oracle db module status

Ronald Hiller ron@graburn.com
Thu, 03 Dec 1998 22:05:50 -0500


The digicool freebie module returns all rows to the python caller, but
fetches them from Oracle one at a time...hence my "no worse.." comment.  A
closer read of Anthony Baxter's module source shows that he fetches from
Oracle in groups of 1000 rows at a time.

However, something in this doesn't seem to work since fetchall() returns a
single row on a large table but all rows on a small table.  I tried sending
Anthony mail, but it seems "that number has been disconnected".  I will
keep snooping and poking at this.

Ron

At 06:46 PM 12/3/98 -0800, you wrote:
>If that is the behavior, then the modules are *wrong*.  fetchall()
>should return *all* the rows, memory-be-damned. The fetchall() method
>was specified at the request of a number of users; Joel Shprentz was the
>specific motivator, as I recall -- he had some excellent arguments for
>its inclusion.
>
>Further, fetchmany() should return the number that you request. Any
>fewer, and that means that there aren't any more (much like a read()).
>
>If any module does not obey those rules, then I'd question their
>compliance to the DBAPI.
>
>-g
>
>Ronald Hiller wrote:
>> 
>> I had the same experience as you in that fetchmany() returns a single row
>> from a large table.
>> 
>> It appears that there is a limit on the number of things returned by the
>> fetchmany() call (it is set to 1000 in Anthony Baxter's version).  This
>> still doesn't explain all of the behavior I see, but it helps!
>> 
>> Anyways, one solution is:
>> def myfetchmany(cursor):
>>         res = []
>>         while 1:
>>                 r = cursor.fetchone()
>>                 if not r: break
>>                 res.append(r)
>>         return res
>> 
>> A look back at the Digicool freebie module shows it always fetches one row
>> at a time so this will be no worse.
>> 
>> I had some problems with the Digicool freebie module with core dumps and
>> infinite loops (always in the cleanup when Python was cleaning up to exit).
>> 
>> Ron
>> ==========================================================
>> Ronald Hiller                     Graburn Technology, Inc.
>> Phone: (732) 845-3999             Suite 250
>> FAX:   (732) 446-6835             716 Newman Springs Road
>> email: ron@graburn.com            Lincroft, NJ 07738
>> ==========================================================
>> 
>> >[cross-posted to DB-SIG, in case someone there cares. I don't subscribe to
>> >DB-SIG though, so please CC me any relevant followups]
>> >
>> >[Aaron_Watters@my-dejanews.com]
>> >>   richard.jones@fulcrum.com.au wrote:
>> >> >     I need an interface to Oracle 8, and am finding that most of the
>> oracle
>> >> > modules out there (except the Digicool one, but I don't have the
>> option of
>> >> > paying for it) are a little out of date with respect to Oracle 8.
>> >>
>> >> I've used the oracledb module (the freebie) from digicool
>> >> with oracle 8, and after the horrible fight to get it linked
>> >> it seemed to work without a problem.  I also know someone
>> >> who is using Anthony Baxter's version and it seems to work
>> >> good for him.
>> >
>> >    Well, to expand a little on the post I made... I have Anthony Baxter's
>> >oracledb module linked fine with 8.0.5 now. I patched the Makefile to
>> include
>> >${ORACLE_HOME}/rdbms/lib/env_rdbms.mk and then linked with ${TTLIBS}. My
>> >problem was that my test select wasn't working properly. After
investigating
>> >further, I find that a "select * from tab" only returns a row at a time
when
>> >fetchall()'ed, but a regular table that I make will return all rows on a
>> >fetchall(). This is all a bit dodgy, and may result in the killing of
Python
>> >from the project I'm working on.

>> >
>> >   Now for the icky bit... looking in the 8.0.4 documentation for OCI, I
>> find
>> >that all the functions used in oracledb are now deprecated. *sigh*
>> >
>> >
>> >> Conceivably (dunno) it should be possible to
>> >> use M.A.Lemburg's mxODBC or (on win32) Bill Tutt's odbc module
>> >> or, if you diverge from Greg Stein's dbapi, Sam Rushing's
>> >> more direct odbc binding too on win32.  Dunno if this helps.
>> >> It's all very confusing.
>> >
>> >    ODBC isn't an option, unfortunately.
>> >
>> >
>> >> The problem with diversity is it's so diverse, when all
>> >> you wanna do is get the job done!  I think I posted a makefile
>> >> for oracle8/oracledbmodule to the dbsig many months ago.
>> >
>> >    Well, here's the snippet that works for me: this is the last few lines
>> of
>> >the Makefile...
>> >
>> >include ${ORACLE_HOME}/rdbms/lib/env_rdbms.mk
>> >oradbmodule.o: $(srcdir)/oradbmodule.c; $(CC) $(CCSHARED) $(CFLAGS)  -I.
>> -I. -c
>> >$(srcdir)/oradbmodule.c
>> >dbi.o: $(srcdir)/dbi.c; $(CC) $(CCSHARED) $(CFLAGS)  -I. -I. -c
>> $(srcdir)/dbi.c
>> >oracledbmodule$(SO):  oradbmodule.o dbi.o; $(LDSHARED)  oradbmodule.o
>> dbi.o  -L$
>> >{ORACLE_HOME}/lib ${TTLIBS} -lsocket -lgen -ldl -lc -laio -lm -o
>> oracledbmodule$
>> >(SO)
>> >
>> >    (Note that the oradbmodule.o, dbi.o and oracledbmodule$(SO) lines
>> should be
>> >1 line - but my mail program might break them)
>> >
>> >
>> >
>> >       Richard
>> >
>> >--
>> >Richard Jones,  developer for the Fulcrum Consulting Group.   (03) 9621
2100
>> >http://www.fulcrum.com.au/
http://alumni.dgs.monash.edu.au/~richard/
>> >
>> 
>> _______________________________________________
>> DB-SIG maillist  -  DB-SIG@python.org
>> http://www.python.org/mailman/listinfo/db-sig
>
>--
>Greg Stein, http://www.lyra.org/
>
>_______________________________________________
>DB-SIG maillist  -  DB-SIG@python.org
>http://www.python.org/mailman/listinfo/db-sig
>