Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Have a look at the <a href="http://www.python.org/dev/peps/pep-0249/" rel="nofollow">Python Database API specification</a> as it answers some of your questions. For example, on NULL values the API specification says this:</p> <blockquote> <p>SQL NULL values are represented by the Python None singleton on input and output.</p> </blockquote> <p>and on parameter styles the specification offers multiple options to the implementer, including the <code>'format'</code> option that MySQLdb uses.</p> <p>If you want to see what query MySQLdb will execute against your database you can cheat a little and use the connections <code>literal(...)</code> method. For example:</p> <pre><code>&gt;&gt;&gt; import MySQLdb &gt;&gt;&gt; db = MySQLdb.connect(...) &gt;&gt;&gt; print "insert into table VALUES ( %s, %s, %s )" % db.literal((5, "ab'c", None)) insert into table VALUES ( 5, 'ab\\'c', NULL ) </code></pre> <p>However the <code>db.literal(...)</code> method isn't really meant to be used by clients of the MySQLdb module, so don't put it in production code.</p> <p>Also, note that the <a href="http://mysql-python.sourceforge.net/MySQLdb.html#mysqldb" rel="nofollow">MySQLdb documentation</a> has this to say about parameters:</p> <blockquote> <p>Parameter placeholders can only be used to insert column values. They can not be used for other parts of SQL, such as table names, statements, etc.</p> </blockquote> <p>So beware of using the parameter placeholders for the column names of a table in an insert statement.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload