[pysqlite] Bind a table name using APSW
"Jason Chang" <[email protected]> Thu, 17 Jul 2008 03:05:02 -0400
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I'm trying out APSW 3.5.9-r2. I'd like to parameterize a SELECT query
so that the table name in the FROM clause can be bound at runtime.
Something like:
SELECT count(idFile) FROM ?
and then to run it:
curs.execute("SELECT count(idFile) FROM ?", ("music",))
But this raises a SQLError with the explanation 'near "?": syntax error'.
I thought perhaps what's happening is that execute() treats the
parameter as text, and so encloses it in quotes, and the database
engine doesn't like that; but the following:
curs.execute("SELECT count(idFile) FROM 'music'")
works fine. (Although admittedly, I feel like I am abusing the
standard here.) Any ideas for further inquiry or better solutions?
Thanks,
Jason