Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #33 from ThiefMaster/patch-1

Update python example
  • Loading branch information...
commit f5a8d4a19f88b2391ee081edeae3e8d8e65230e3 2 parents 6bc62ce + 378017e
@petdance authored
Showing with 28 additions and 1 deletion.
  1. +28 −1 s/
29 s/
@@ -9,7 +9,34 @@ Using the [Python DB API](, don
Instead, do this:
- curs.execute('update people set name=:1 where id=:2', [name, id])
+ cmd = "update people set name=%s where id=%s"
+ curs.execute(cmd, (name, id))
+Note that the placeholder syntax depends on the database you are using.
+ 'qmark' Question mark style,
+ e.g. '...WHERE name=?'
+ 'numeric' Numeric, positional style,
+ e.g. '...WHERE name=:1'
+ 'named' Named style,
+ e.g. '...WHERE name=:name'
+ 'format' ANSI C printf format codes,
+ e.g. '...WHERE name=%s'
+ 'pyformat' Python extended format codes,
+ e.g. '...WHERE name=%(name)s'
+The values for the most common databases are:
+ >>> import MySQLdb; print MySQLdb.paramstyle
+ format
+ >>> import psycopg2; print psycopg2.paramstyle
+ pyformat
+ >>> import sqlite3; print sqlite3.paramstyle
+ qmark
+So if you are using MySQL or PostgreSQL, use `%s` (even for numbers and
+other non-string values!) and if you are using SQLite use `?`
To do
Please sign in to comment.
Something went wrong with that request. Please try again.