Re: catching SQL string returned to sqlite
Gerhard Häring <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Eric S. Johansson wrote:
> is there any way to catch the final string just before it is passed to
> sqlite?
>
> I have query that is failing (you've seen it before) and I verified that
> all the data is in the table as verified by the sqlite commandline tool
> and I'm handing it the right key. I think I have all my tuples lined up
> in a row and yet, I can't find the specified record. is there any way
> to somehow look within pysqlite and see what's being sent to sqlite?
pysqlite sends exactly the string you give to execute() to the SQLite
library. There is no parameter *substitution* taking place. Instead,
parameter *binding* is taking place. I. e. this:
cursor.execute("select a, b, c from tab1 where d=? and e=?", ("x", 1))
is executed as roughly this:
statement = sqlite_api.compile_statement("select a, b, c from tab1 where
d=? and e=?")
statement.bind_parameter(0, "x", SQLITE_TEXT)
statement.bind_parameter(1, 1, SQLITE_NUMERIC)
> Related, it is it possible that I can't use a key with an '@' in it?
I'm not sure what you mean with "key"!? Strings can contain any
characters except ASCII 0 in SQLite.
Can you try to post example code that shows the problem?
-- Gerhard