[DB-SIG] Python database API 2.0/returning Column names with data
David A McInnis
Sun, 4 Nov 2001 06:56:57 -0800
I found another one myself, for MySQLdb (I am using MySQL).
It appears that cursorclass= is undocumented as well.
If you set cursorclass=MySQLdb.cursors.DictCursor, a dictionary is returned
which contains the row names.
db1 = MySQLdb.connect(user = "username", passwd="password", host= "host", db
= "database", cursorclass=MySQLdb.cursors.DictCursor)
c1 = db1.cursor()
c1.execute("""SELECT * from table where email = %s""",
row1 = c1.fetchone()
From: email@example.com [mailto:firstname.lastname@example.org]On Behalf
Of Gary Maynard
Sent: Sunday, November 04, 2001 2:38 AM
Subject: Re: [DB-SIG] Python database API 2.0/returning Column names
Thanks everybody for your help with this. I got it working without too much
trouble after I read your messages.
As a Python Newbie though, may I suggest that this kind if information be
made more readily available? the Cursor.description function that is
required to do this is not listed in the API and thus seems almost to be an
DB-SIG maillist - DB-SIG@python.org