From ef219d6b4df6cfcbefd5fd989a9c16ec3fcdb99c Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 11 Dec 2020 21:48:13 -0800 Subject: [PATCH] -c / --column option --- sqlite_utils/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 6cd23f7..7e653e6 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -1361,11 +1361,13 @@ def insert_files( required=True, ) @click.argument("tables", nargs=-1) +@click.option("-c", "--column", "columns", type=str, multiple=True, help="Specific columns to analyze") @click.option("--save", is_flag=True, help="Save results to _analyze_tables table") @load_extension_option def analyze_tables( path, tables, + columns, save, load_extension, ): @@ -1379,7 +1381,8 @@ def analyze_tables( for table in tables: table_counts[table] = db[table].count for column in db[table].columns: - todo.append((table, column.name)) + if (not columns or column.name in columns): + todo.append((table, column.name)) # Now we now how many we need to do for i, (table, column) in enumerate(todo): column_details = db[table].analyze_column(column, total_rows=table_counts[table])