[Tutor] what is wrong with this code?
steve at alchemy.com
Mon Apr 26 19:58:35 CEST 2010
On Mon, Apr 26, 2010 at 07:53:17PM +0200, Norman Khine wrote:
> ok this worked,
> cursor.execute(drop_user_tables % ",".join(user_tables))
> it seems that DROP TABLE (and other DDL statements) don't technically
> take SQL parameters.
That's correct. The point of using %s as a placeholder for an SQL
value (not to be confused with %s in string formatting with the % operator
in Python), is to prevent them from being confused with SQL *statement*
code but made into proper values (strings, integers, and so forth).
But the names of tables, fields, etc., are NOT values, they are part
of the SQL syntax and you have to build them as part of the string
Steve Willoughby | Using billion-dollar satellites
steve at alchemy.com | to hunt for Tupperware.
More information about the Tutor