mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 01:44:31 +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
|
|
@ -1006,6 +1006,12 @@ def transform(
|
|||
multiple=True,
|
||||
help="Rename this column in extracted table",
|
||||
)
|
||||
@click.option(
|
||||
"-s",
|
||||
"--silent",
|
||||
is_flag=True,
|
||||
help="Don't show progress bar",
|
||||
)
|
||||
def extract(
|
||||
path,
|
||||
table,
|
||||
|
|
@ -1013,12 +1019,24 @@ def extract(
|
|||
other_table,
|
||||
fk_column,
|
||||
rename,
|
||||
silent,
|
||||
):
|
||||
"Extract one or more columns into a separate table"
|
||||
db = sqlite_utils.Database(path)
|
||||
db[table].extract(
|
||||
columns, table=other_table, fk_column=fk_column, rename=dict(rename)
|
||||
kwargs = dict(
|
||||
columns=columns,
|
||||
table=other_table,
|
||||
fk_column=fk_column,
|
||||
rename=dict(rename),
|
||||
)
|
||||
if silent:
|
||||
db[table].extract(**kwargs)
|
||||
else:
|
||||
with click.progressbar(
|
||||
length=db[table].count, label="Extracting columns"
|
||||
) as bar:
|
||||
kwargs["progress"] = bar.update
|
||||
db[table].extract(**kwargs)
|
||||
|
||||
|
||||
@cli.command(name="insert-files")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue