db.py: Support pyformat paramstyle

This is used by the MySQL database backend.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2016-08-14 21:56:41 +02:00
parent 4a355c71cb
commit 2c36c17a18

View file

@ -32,7 +32,7 @@ class Connection:
raise ValueError('unsupported database backend') raise ValueError('unsupported database backend')
def execute(self, query, params=()): def execute(self, query, params=()):
if self._paramstyle == 'format': if self._paramstyle in ('format', 'pyformat'):
query = query.replace('%', '%%').replace('?', '%s') query = query.replace('%', '%%').replace('?', '%s')
elif self._paramstyle == 'qmark': elif self._paramstyle == 'qmark':
pass pass