mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-24 19:04:12 +02:00
Allow surrogates in parameters
closes #507 https://dwheeler.com/essays/fixing-unix-linux-filenames.html
This commit is contained in:
parent
529110e7d8
commit
2d6a14938a
1 changed files with 12 additions and 6 deletions
|
|
@ -477,12 +477,18 @@ class Database:
|
||||||
:param parameters: Parameters to use in that query - an iterable for ``where id = ?``
|
:param parameters: Parameters to use in that query - an iterable for ``where id = ?``
|
||||||
parameters, or a dictionary for ``where id = :id``
|
parameters, or a dictionary for ``where id = :id``
|
||||||
"""
|
"""
|
||||||
if self._tracer:
|
try:
|
||||||
self._tracer(sql, parameters)
|
if self._tracer:
|
||||||
if parameters is not None:
|
self._tracer(sql, parameters)
|
||||||
return self.conn.execute(sql, parameters)
|
if parameters is not None:
|
||||||
else:
|
return self.conn.execute(sql, parameters)
|
||||||
return self.conn.execute(sql)
|
else:
|
||||||
|
return self.conn.execute(sql)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
sql = sql.encode('utf-8', 'surrogatepass').decode('utf-8')
|
||||||
|
if parameters is not None:
|
||||||
|
parameters = parameters.encode('utf-8', 'surrogatepass').decode('utf-8')
|
||||||
|
return self.execute(sql, parameters)
|
||||||
|
|
||||||
def executescript(self, sql: str) -> sqlite3.Cursor:
|
def executescript(self, sql: str) -> sqlite3.Cursor:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue