This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zzzeek
Recipients zzzeek
Date 2014-06-11.13:11:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1402492269.75.0.610341668437.issue21718@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-06-11 13:11:09zzzeeksetrecipients: + zzzeek
2014-06-11 13:11:09zzzeeksetmessageid: <1402492269.75.0.610341668437.issue21718@psf.upfronthosting.co.za>
2014-06-11 13:11:09zzzeeklinkissue21718 messages
2014-06-11 13:11:09zzzeekcreate