|
Re: Getting the time during a transaction: msg#00014python.db.pysqlite.user
David Pratt wrote: > Hi Tim. It was a surprise to me as well! The thing that screwed me up > was assert cursor.rowcount. Hmm, it should be 1 since I am getting a > result from .fetchone but is reporting -1. I incorrectly assumed I was > getting nothing from my select statement. Any idea about this? Why is it > not giving me a rowcount of 1 so my assertion is correct? Another of those quirks, I'm afraid. If you haven't already, read the usage guide of the pysqlite website: http://initd.org/pub/software/pysqlite/doc/usage-guide.html and in particular the section on extensions and caveats: http://initd.org/pub/software/pysqlite/doc/usage-guide.html#extensions-and-caveats Search the page for "rowcount attribute" and you find: """ Although pysqlite's Cursors implement this attribute, the database engine's own support for the determination of "rows affected"/"rows selected" is quirky. For SELECT statements, rowcount is always -1 because pysqlite cannot determine the number of rows a query produced until all rows were fetched. """ which I think answers your question. BTW, it obviously depends what your plan is, but I've been programming databases professionally for over 15 years and I can't remember the last time I catually had to use rowcount (or its equivalent). Could be a shortcoming on my part, obviously, but I wonder whether there's some other way you might achieve what you're trying to do. TJG |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Emulating a sequence: 00014, David Pratt |
|---|---|
| Next by Date: | Re: Emulating a sequence: 00014, Tim Golden |
| Previous by Thread: | Re: Getting the time during a transactioni: 00014, David Pratt |
| Next by Thread: | Re: Getting the time during a transaction: 00014, David Pratt |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |