Using strings with ' in them in SQL-queries

thomas at thomas at
Tue May 30 16:27:49 EDT 2000


I need to insert strings with ' in them in query-strings. I`m using
the PostgreSQL-database. 

If I try stuff like this :

db = _pg.connection(....)
db.query('insert into test (id, name) value (1, 'fdsfds''fdsf') ')

That works ok. But the string I need to insert I get from a variable. 
I cannot seem to use a variable in the query-string. Is there any way
around this? How can I handle characters in strings that may
comprimise the requirements of a valid sql-statement??


More information about the Python-list mailing list