%s place holder does not let me insert ' in an sql query with python.

K

Krishnakant

hello all hackers.
This is some kind of an interesting situation although many of you must
have already gone through it.
I am facing a situation where I have to use psycopg2 and insert rows in
a postgresql table.
That's pritty easy and no need to say that it works well. But there are
some entries which have an ' in the value.
I have a venders table in my database and one of the values tryed was
"His Master's Voice "
now the master's word has the ' which is used for starting and ending a
varchar value for postgresql or almost any standard RDBMS.
Does any one know what is the way out of this?
how do you let the ' go as a part of the string?
I have used %s as placeholder as in
queryString = "insert into venders values ('%s,%s,%s" %
(field1,field2,field3 ) ...
This is not working for the ' values.
can any one suggest a suitable solution?
happy hacking.
Krishnakant.
 

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top