pythonでのparepared statementのplaceholderの話

とりあえずdbapi2.0を見る。

https://www.python.org/dev/peps/pep-0249/#paramstyle

以下の様な種類の表記が使われるらしい

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 

sqlite3のdocumentを見る

https://docs.python.org/3/library/sqlite3.html?highlight=sqlite3#module-sqlite3

Instead, use the DB-API’s parameter substitution. Put ? as a placeholder wherever you want to use a value, and then provide a tuple of values as the second argument to the cursor’s execute() method. (Other database modules may use a different placeholder, such as %s or :1.) For example:

? を使うらしい。dbapi2.0で挙げられている表記の内どれが利用可能か調べてみる。

gist315393fdc4b0b95ea327

無難に ? を使うことにする。他のdb moduleの場合placeholderに違う物を使っていたような記憶がある。