Re: Wierd "ProgrammingError" with "E" string prefix

Tim Roberts <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization Providenza & Boekelheide, Inc.
Message-ID <[email protected]>
Hartmut Goebel wrote:
> Hi Federico,
>
> I'm experiencing a wierd "ProgrammingError" psycopg2 2.0.7:
>
>   psycopg2.ProgrammingError: FEHLER:  Syntaxfehler bei »E'Table_One'«
>   LINE 1: DROP TABLE E'Table_One'
>
> psycopg seams to "quote" the table name with an "E" prefix.
> ...
> cur.execute("DROP TABLE %s", (table_name,))
>
>
> Any help?
>   

Don't let psycopg do the quoting for table and field names.  The
automatic quoting is ONLY appropriate for field values.  Just use the
normal % operator:
    cur.execute("DROP TABLE %s"  %  table_name )

-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.