pysqlite2 fetching from select different than pysqlite?
Tim Golden
tim.golden at viacom-outdoor.co.uk
Thu Jul 27 10:14:56 EDT 2006
[schwehr at gmail.com]
| Sent: 27 July 2006 15:01
| To: python-list at python.org
| Subject: Re: pysqlite2 fetching from select different than pysqlite?
|
| Thanks Tim! That works well. As a followup, is there a standard
| compliant way to ask what fields are in the table?
|
| -kurt
Assuming this is what you meant, look at:
http://sqlite.org/pragma.html
specifically at PRAGMA table_info
So, in python:
<python>
from pysqlite2 import dbapi2 as sqlite
db = sqlite.connect (":memory:")
db.row_factory = sqlite.Row
db.execute ("CREATE TABLE x (i INTEGER, code VARCHAR (10), name VARCHAR
(60))")
for row in db.execute ("PRAGMA TABLE_INFO ('x')"):
print row['name'], row['type']
</python>
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list