...
sql = "SELECT * FROM table WHERE value=$my_value AND string=$username",
vars={'my_value':17, 'username':"String"}
print sql
db_rows = db.conn.query(sql)
…
I think it'll be solve your problem.
On Jan 26, 2013, at 7:31 AM, David Lewis <[email protected]>
wrote:
> o read-back the SQL string used in Query() in Web.Py/Python 2.7
> up vote
> 0
> down vote
> favorite
> I'm making a connection to a MySql database, in Python 2.7 & Web.Py, using
> the Query() method for escaped input and advanced SQL queries.
>
> A very simplified example follows:
>
> conn = web.database(dbn = 'mysql', db = 'database_name', user =
> 'db_user_name', pw = "db_password")
> db_rows = db.conn.query("SELECT * FROM table WHERE value=$my_value AND
> string=$username", vars={'my_value':17, 'username':"String"})
> for row in db_rows:
> etc
> This is all working fine, but I want to be able to debug things by running
> the same query directly on MySQL, so I can see/validate the results.
>
> To do this, I need to be able to see the whole SQL string that was used,
> together with the injected variables.
>
> Is there any way to read back the actual string that MySql is using for the
> query?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.