simonw / sqlite-utils
Showing 1 of 3 files from the diff.
Other files ignored by Codecov

@@ -1216,6 +1216,11 @@
Loading
1216 1216
    type=click.Path(file_okay=True, dir_okay=False, allow_dash=False),
1217 1217
    help="Save in-memory database to this file",
1218 1218
)
1219 +
@click.option(
1220 +
    "--analyze",
1221 +
    is_flag=True,
1222 +
    help="Analyze resulting tables and output results",
1223 +
)
1219 1224
@load_extension_option
1220 1225
def memory(
1221 1226
    paths,
@@ -1236,6 +1241,7 @@
Loading
1236 1241
    schema,
1237 1242
    dump,
1238 1243
    save,
1244 +
    analyze,
1239 1245
    load_extension,
1240 1246
):
1241 1247
    """Execute SQL query against an in-memory database, optionally populated by imported data
@@ -1265,8 +1271,8 @@
Loading
1265 1271
        sqlite-utils memory animals.csv --schema
1266 1272
    """
1267 1273
    db = sqlite_utils.Database(memory=True)
1268 -
    # If --dump or --save used but no paths detected, assume SQL query is a path:
1269 -
    if (dump or save or schema) and not paths:
1274 +
    # If --dump or --save or --analyze used but no paths detected, assume SQL query is a path:
1275 +
    if (dump or save or schema or analyze) and not paths:
1270 1276
        paths = [sql]
1271 1277
        sql = None
1272 1278
    for i, path in enumerate(paths):
@@ -1299,6 +1305,10 @@
Loading
1299 1305
            if not db[view_name].exists():
1300 1306
                db.create_view(view_name, "select * from [{}]".format(csv_table))
1301 1307
1308 +
    if analyze:
1309 +
        _analyze(db, tables=None, columns=None, save=False)
1310 +
        return
1311 +
1302 1312
    if dump:
1303 1313
        for line in db.conn.iterdump():
1304 1314
            click.echo(line)
@@ -1922,6 +1932,10 @@
Loading
1922 1932
    "Analyze the columns in one or more tables"
1923 1933
    db = sqlite_utils.Database(path)
1924 1934
    _load_extensions(db, load_extension)
1935 +
    _analyze(db, tables, columns, save)
1936 +
1937 +
1938 +
def _analyze(db, tables, columns, save):
1925 1939
    if not tables:
1926 1940
        tables = db.table_names()
1927 1941
    todo = []
Files Coverage
sqlite_utils 96.42%
Project Totals (5 files) 96.42%
1
coverage:
2
  status:
3
    project:
4
      default:
5
        informational: true
6
    patch:
7
      default:
8
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading