Re: Error with ALTER TABLE %s

Tim Roberts <[email protected]> Tue, 04 May 2010 10:08:36 -0700
Newsgroups gmane.comp.python.db.psycopg.devel
Organization Providenza & Boekelheide, Inc.
Message-ID <[email protected]>
Federico Di Gregorio wrote:
> On 04/05/2010 13:54, [email protected] wrote:
>   
>> Hi, when I do
>> SQL = "ALTER TABLE films ADD COLUMN (%s) text;"
>> data = ("test3", )
>> cur.execute(SQL,data)
>>
>> I get this error,
>>
>> LINE 1: ALTER TABLE films ADD COLUMN (E'test3') text;
>>     
>
> You can't use bound variables with column (or table, or functions, etc.)
> names.
>   

Right, so for posterity's sake, the OP should just use this:
   cur.execute(SQL % data)

-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.