Varibles in SQL statements
Lee, Jaeho
Jhlee at Brooks.com
Fri May 19 13:56:45 EDT 2000
Do you want to use Oracle bind variable?
If not you can do this.
var = "'1'"
mycursor.execute("SELECT userID FROM userTable WHERE userID=%s" % var)
In sql, string should be quoted (not double quoted). And excute() method
receives just string in this case. var in your sql is just var and the
database try to find a database field named 'var'. That's why.
I don't know how to use bind variable. So I can not help for that.
-----Original Message-----
From: relder at omegabit.com [mailto:relder at omegabit.com]
Sent: Friday, May 19, 2000 1:38 PM
To: python-list at python.org
Subject: Varibles in SQL statements
Hello,
I don't understand how to use (or format really) varibles in SQL.With
the sequence
var = '1'
mycursor.execute('SELECT userID FROM userTable WHERE userID=var')
I get a too few paramerters error
This does work:
mycursor.execute("SELECT userID FROM userTable WHERE userID='1'")
???
TIA.
-r
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list