kopia lustrzana https://github.com/simonw/datasette
Don't crash on weird character encodings
Expecting SQLite columns to all be valid utf8 doesn't work, because we are deailing with all kinds of databases. Instead, we now use the 'replace' encoding mode to replace any non-UTF8 characters with a [X] character.pull/383/head
rodzic
c371f06fde
commit
4c7379a898
3
app.py
3
app.py
|
|
@ -34,6 +34,7 @@ def get_conn(name):
|
|||
uri=True
|
||||
)
|
||||
conns[name].row_factory = sqlite3.Row
|
||||
conns[name].text_factory = lambda x: str(x, 'utf-8', 'replace')
|
||||
return conns[name]
|
||||
|
||||
|
||||
|
|
@ -279,7 +280,7 @@ def pks_for_table(conn, table):
|
|||
if row[-1]
|
||||
]
|
||||
rows.sort(key=lambda row: row[-1])
|
||||
return [r[1] for r in rows]
|
||||
return [str(r[1]) for r in rows]
|
||||
|
||||
|
||||
def path_from_row_pks(row, pks):
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue