title: Forming an insert statement with single quotes in Python with Postgres
body: <p>I am having a field called comments.
  I am effectively trying to read values from one large table into multiple tables.
  Hence, my select query fetches the comment field for me.</p>
  
  <p>I am constructing a Python script to do the copying from table to table.
  My insert query fails when it encounters a comment field like "Sorry! we can't process your order" because of the single quote.</p>
  
  <p>I have tried using $ quotes but in vain</p>
  
  <p>Here is what I am trying</p>
  
  <pre><code>#!/usr/bin/python
  
  import psycopg2
  
  conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' )
  mark=conn.cursor()
  /* fectching the rows and doing other stuff */
  
  addthis="insert into my_table(something) values("$$"+str(row[8])+"$$")
  mark.execute(addthis)
  conn.commit()
  </code></pre>
  
  <p>Appreciate the help!</p>