Message220263
Per DBAPI and pysqlite docs, .description must be available for any SELECT statement regardless of whether or not rows are returned. However, this fails for SELECT statements that aren't simple "SELECT"s, such as those that use CTEs and therefore start out with "WITH:":
import sqlite3
conn = sqlite3.connect(":memory:")
cursor = conn.cursor()
cursor.execute("""
create table foo (id integer primary key, data varchar(20))
""")
cursor.execute("""
insert into foo (id, data) values (10, 'ten')
""")
cursor.execute("""
with bar as (select * from foo)
select * from bar where id = 10
""")
assert cursor.description is not None
cursor.execute("""
with bar as (select * from foo)
select * from bar where id = 11
""")
assert cursor.description is not None
the second statement returns no rows and cursor.description is None. Libraries like SQLAlchemy which rely on this to determine that the statement supports fetchone() and similar are blocked. |
|
Date |
User |
Action |
Args |
2014-06-11 13:11:09 | zzzeek | set | recipients:
+ zzzeek |
2014-06-11 13:11:09 | zzzeek | set | messageid: <1402492269.75.0.610341668437.issue21718@psf.upfronthosting.co.za> |
2014-06-11 13:11:09 | zzzeek | link | issue21718 messages |
2014-06-11 13:11:09 | zzzeek | create | |
|