mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
First CLI command: sqlite-utils table_names test.db
This commit is contained in:
parent
8437fe3091
commit
fd5829b27d
4 changed files with 60 additions and 3 deletions
|
|
@ -1,6 +1,22 @@
|
|||
import click
|
||||
import sqlite_utils
|
||||
|
||||
|
||||
@click.command()
|
||||
def cli(*args):
|
||||
click.echo(repr(args))
|
||||
@click.group()
|
||||
@click.version_option()
|
||||
def cli():
|
||||
"Commands for interacting with a SQLite database"
|
||||
pass
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument(
|
||||
"path",
|
||||
type=click.Path(exists=True, file_okay=True, dir_okay=False, allow_dash=False),
|
||||
required=True,
|
||||
)
|
||||
def table_names(path):
|
||||
"""List the tables in the database"""
|
||||
db = sqlite_utils.Database(path)
|
||||
for name in db.table_names:
|
||||
print(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue