mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-15 04:54:23 +02:00
Merge branch 'simonw:main' into main
This commit is contained in:
commit
61de8d997d
7 changed files with 46 additions and 44 deletions
|
|
@ -457,8 +457,7 @@ class Database:
|
|||
fn_name, arity, fn, **dict(kwargs, deterministic=True)
|
||||
)
|
||||
registered = True
|
||||
except (sqlite3.NotSupportedError, TypeError):
|
||||
# TypeError is Python 3.7 "function takes at most 3 arguments"
|
||||
except sqlite3.NotSupportedError:
|
||||
pass
|
||||
if not registered:
|
||||
self.conn.create_function(fn_name, arity, fn, **kwargs)
|
||||
|
|
@ -951,9 +950,9 @@ class Database:
|
|||
" [{column_name}] {column_type}{column_extras}".format(
|
||||
column_name=column_name,
|
||||
column_type=COLUMN_TYPE_MAPPING[column_type],
|
||||
column_extras=(" " + " ".join(column_extras))
|
||||
if column_extras
|
||||
else "",
|
||||
column_extras=(
|
||||
(" " + " ".join(column_extras)) if column_extras else ""
|
||||
),
|
||||
)
|
||||
)
|
||||
extra_pk = ""
|
||||
|
|
@ -1527,9 +1526,11 @@ class Table(Queryable):
|
|||
def __repr__(self) -> str:
|
||||
return "<Table {}{}>".format(
|
||||
self.name,
|
||||
" (does not exist yet)"
|
||||
if not self.exists()
|
||||
else " ({})".format(", ".join(c.name for c in self.columns)),
|
||||
(
|
||||
" (does not exist yet)"
|
||||
if not self.exists()
|
||||
else " ({})".format(", ".join(c.name for c in self.columns))
|
||||
),
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
@ -3001,9 +3002,11 @@ class Table(Queryable):
|
|||
value = jsonify_if_needed(
|
||||
record.get(
|
||||
key,
|
||||
None
|
||||
if key != hash_id
|
||||
else hash_record(record, hash_id_columns),
|
||||
(
|
||||
None
|
||||
if key != hash_id
|
||||
else hash_record(record, hash_id_columns)
|
||||
),
|
||||
)
|
||||
)
|
||||
if key in extracts:
|
||||
|
|
|
|||
|
|
@ -304,10 +304,7 @@ def rows_from_file(
|
|||
rows = rows_from_file(
|
||||
fp, format=Format.CSV, dialect=csv.excel_tab, encoding=encoding
|
||||
)[0]
|
||||
return (
|
||||
_extra_key_strategy(rows, ignore_extras, extras_key),
|
||||
Format.TSV,
|
||||
)
|
||||
return _extra_key_strategy(rows, ignore_extras, extras_key), Format.TSV
|
||||
elif format is None:
|
||||
# Detect the format, then call this recursively
|
||||
buffered = io.BufferedReader(cast(io.RawIOBase, fp), buffer_size=4096)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue