format single quote in SQL statement
<p>My question is simple, in Python, How do I format a SQL statement that contains single quotes in it?</p>

<p>I have a place name</p>

<pre><code>"Musee d'Orsay"
</code></pre>

<p>What I want is </p>

<pre><code>"Musee d\'Orsay"
</code></pre>

<p>so, I tried replace single quote by using following statement</p>

<pre><code>str.replace("'","\'")
</code></pre>

<p>but, it return the original string. Can you give me any help?</p>

<p>double slash worked well.</p>

<pre><code>str.replace("'","\\'")
</code></pre>

<p><hr/>
OK, Thanks for all response. I have figured it out. </p>

<p>I must escape it by doubling the single quote.</p>

<blockquote>
  <p>str.replace("'","''")</p>
  
  <p>INSERT INTO table_name VALUES (Musee d''Orsay);</p>
</blockquote>

<p>It works for me. </p>
