Re: Opening a DB Connection
Rich Shepard <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 30 Sep 2006, Gerhard Häring wrote:
> So the best I know is the database API specification itself at
> http://www.python.org/dev/peps/pep-0249/ in the section cursor methods.
Gerhard,
Of course! I did not remember to go look there. I have a printed copy
somewhere in my office here.
> In our case, fetchone()[0]:
>
> fetchone() returns one row from the result set as a sequence. fetchone()[0]
> thus is the value of the first column of the first row of the result set. I
> use this construction for SELECT statements that only return a single value.
I thought that was how it was read. The confirmation is valuable.
> The recommended way to iterate through a resultset is to just iterate over
> the cursor:
>
> cur.execute("select a, b, c from testtable")
> for row in cur:
> print row
>
> The other methods that are available are fetchonemany() and fetchall().
> fetchmany(n) is used to iterate over the result set in batches of n rows,
> and fetchall just returns the whole result set as a list of sequences.
Thank you very much. This is exactly the insight I need, and I'll go read
the DBAPI-2 for the rest of my education.
Much appreciated,
Rich
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite