Re: [Sqlrelay-discussion] Python bindings and rowcount
Brought to you by:
mused
|
From: David M. <dav...@fi...> - 2008-05-21 03:51:48
|
Yeah, I wasn't really sure what cur.rowcount should return.
When using PySQLRClient, rowCount() will return the number of rows
fetched from the DB so far. The PySQLRDB client caches the entire
result set so rowCount() will return the total number of rows in the
result set. There's another method totalRows() that gets the number of
rows in the result set directly from the db. Many db's don't support
that feature, so totalRows() returns 0 for those. In PySQLRDB, rowcount
is set from totalRows(). I thought this would be appropriate because
you'd get the same result if you connected directly to the db.
However, if you'd like to change that behavior, just edit
src/api/python/PySQLRDB.py and replace all instances of totalRows with
rowCount and reinstall.
David Muse
dav...@fi...
On Fri, 2008-05-09 at 15:39 -0400, Jonathan Kaczynski wrote:
> Hi,
>
> (This is a resend because I didn't see it show up in the mailing list.)
>
> I'm running the latest release of SQLRelay, 0.39.4, which is talking to an Oracle database.
>
> I've looked at the archives of the mailing list and haven't seen my issue mentioned before.
>
> I have a problem with the python db api 2.0-esque bindings, PySQLRDB; cur.rowcount always returns 0 (cur.rowCount() from PySQLClient works fine).
>
>
>
> >>> from SQLRelay import PySQLRDB
> >>> con = PySQLRDB.connect('localhost', 9200, '', 'username', 'password', 0, 1)
> >>> cur = con.cursor()
> >>> cur.execute("select 1 from dual")
> >>> cur.rowcount
> 0
> >>> cur.fetchall()
> [[Decimal("1")]]
> >>> cur.rowcount
> 0
>
>
>
> >>> from SQLRelay import PySQLRClient
> >>> con = PySQLRClient.sqlrconnection('localhost', 9200, '', 'username', 'password', 0, 1)
> >>> cur = PySQLRClient.sqlrcursor(con)
> >>> cur.sendQuery("select 1 from dual")
> 1
> >>> cur.rowCount()
> 1
>
>
>
> I looked at PySQLRDB.py, PySQLRClient.py, and CSQLRelay.C.
>
> In rowCount(), in PySQLRClient.py, the value returned comes from CSQLRelay.rowCount(self.cursor), which comes from ((sqlrcursor *)sqlrcur)->rowCount().
>
> In execute(), in PySQLRDB.py, rowcount is assigned to either CSQLRelay.totalRows(self.cursor) or CSQLRelay.affectedRows(self.cursor), which come from ((sqlrcursor *)sqlrcur)->totalRows() or ((sqlrcursor *)sqlrcur)->affectedRows(), respectively.
>
> So, rowCount returns 1, and both totalRows and affectedRows return 0.
>
> Does anyone know why cur.rowcount, from PySQLRDB.py, would always return 0?
>
> Thank you,
> Jonathan Kaczynski
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Sqlrelay-discussion mailing list
> Sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion
>
>
> __________________________________________________
> D O T E A S Y - "Join the web hosting revolution!"
> http://www.doteasy.com
__________________________________________________
D O T E A S Y - "Join the web hosting revolution!"
http://www.doteasy.com
|