sqlite-utils transform --column-order option, closes #176

This commit is contained in:
Simon Willison 2020-09-24 09:11:53 -07:00
commit d13c123100
3 changed files with 10 additions and 0 deletions

View file

@ -904,6 +904,7 @@ def rows(ctx, path, dbtable, nl, arrays, csv, no_headers, table, fmt, json_cols)
@click.option(
"--rename", type=(str, str), multiple=True, help="Rename this column to X"
)
@click.option("-o", "--column-order", type=str, multiple=True, help="Reorder columns")
@click.option("--not-null", type=str, multiple=True, help="Set this column to NOT NULL")
@click.option(
"--not-null-false", type=str, multiple=True, help="Remove NOT NULL from this column"
@ -934,6 +935,7 @@ def transform(
type,
drop,
rename,
column_order,
not_null,
not_null_false,
pk,
@ -969,6 +971,7 @@ def transform(
kwargs["types"] = types
kwargs["drop"] = set(drop)
kwargs["rename"] = dict(rename)
kwargs["column_order"] = column_order or None
kwargs["not_null"] = not_null_dict
if pk:
if len(pk) == 1: