lundi 30 mars 2015

Python: how to Insert value into table postgresql?

how to format the string to insert it into a table in postgresql? example I have the sql:



req="INSERT INTO table_a values('%s','%s','%s')"


and the values



values=["Socit d'Invest Variable", '6465', 'hg', 'fk_id']
cursor.execute(req,tuple(values))


I get the error :



psycopg2.ProgrammingError: syntax error at or near "Socit"
LINE 1: ...column0, column1, column2, column3) Values (''Socit d'Invest...


any Idea how to change the string from using a single quote ' to a double quote " ?


Aucun commentaire:

Enregistrer un commentaire