un-tuple (newbie)
Martin Doering
doeringm at gmx.de
Tue Dec 2 06:44:47 EST 2003
On Mon, 01 Dec 2003 13:44:57 -0800, sdd <daniels at dsl-only.net> wrote:
>Personally, I'd call it "cursor", not "c". Also my DB predeliction
>leads me to prefer calling it a "row", not a "line".
Yes, for shure. It was my first try. :-)
>If you know (and don't care to check) that a single row is returned,
>with a single value, I might try something like this:
>
> def single_value_query(db, sql):
> cursor = db.cursor()
> try:
> cursor.execute(sql)
> return cursor.fetchone()[0]
> finally:
> cursor.close()
Ah! This is exactly, what I was searching for. For shure, I must force
the query to just deliver ONE value back.
Thanks also to Heather. The indexing was the bit I did not know till
now.
The more I do with [J|Y]ython, the more I like the language. Very
elegant and clear to read. :-)
--
Martin
More information about the Python-list
mailing list