When using ready-made statements with named parameters in SQLite (in particular, with the python sqlite3 module http://docs.python.org/library/sqlite3.html ), can you include string values ββin any case without getting quotes around them?
I have it:
columnName = '''C1''' cur = cur.execute('''SELECT DISTINCT(:colName) FROM T1''', {'colName': columnName})
And it looks like SQL, in the end I get the following:
SELECT DISTINCT('C1') FROM T1
which, of course, is not very useful, I really want:
SELECT DISTINCT(C1) FROM T1 .
Is there a way to get the execute method to interpret the provided arguments so that they don't exchange quotes around them?
I wrote a small test program to fully explore it, as it stands here:
import sys import sqlite3 def getDatabaseConnection(): DEFAULTDBPATH = ':memory:' conn = sqlite3.connect(DEFAULTDBPATH, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) conn.text_factory = str return conn def initializeDBTables(conn): conn.execute(''' CREATE TABLE T1( id INTEGER PRIMARY KEY AUTOINCREMENT, C1 STRING);''') cur = conn.cursor() cur.row_factory = sqlite3.Row
It would be interesting to hear about any case of manipulation of the execute method so that this can work.
source share