mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
Progress bar for "sqlite-utils extract", closes #169
This commit is contained in:
parent
55cf928f73
commit
5c4d58d152
3 changed files with 26 additions and 3 deletions
|
|
@ -883,7 +883,7 @@ class Table(Queryable):
|
|||
|
||||
return sqls
|
||||
|
||||
def extract(self, columns, table=None, fk_column=None, rename=None):
|
||||
def extract(self, columns, table=None, fk_column=None, rename=None, progress=None):
|
||||
rename = rename or {}
|
||||
if isinstance(columns, str):
|
||||
columns = [columns]
|
||||
|
|
@ -905,6 +905,8 @@ class Table(Queryable):
|
|||
row_pks = tuple(row[pk] for pk in pks)
|
||||
lookups = {rename.get(column) or column: row[column] for column in columns}
|
||||
self.update(row_pks, {first_column: lookup_table.lookup(lookups)})
|
||||
if progress:
|
||||
progress(1)
|
||||
fk_column = fk_column or "{}_id".format(table)
|
||||
# Now rename first_column and change its type to integer, and drop
|
||||
# any other extracted columns:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue