'sqlite-utils add-column name type' command, closes #15

This commit is contained in:
Simon Willison 2019-02-24 12:04:33 -08:00
commit 0bc49e938e
5 changed files with 80 additions and 8 deletions

View file

@ -134,6 +134,26 @@ def optimize(path, no_vacuum):
db.vacuum()
@cli.command(name="add-column")
@click.argument(
"path",
type=click.Path(exists=True, file_okay=True, dir_okay=False, allow_dash=False),
required=True,
)
@click.argument("table")
@click.argument("col_name")
@click.argument(
"col_type",
type=click.Choice(
["integer", "float", "blob", "text", "INTEGER", "FLOAT", "BLOB", "TEXT"]
),
)
def add_column(path, table, col_name, col_type):
"Add a column to the specified table"
db = sqlite_utils.Database(path)
db[table].add_column(col_name, col_type)
@cli.command(name="create-index")
@click.argument(
"path",