mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
db.table() only returns tables, added db.view()
* db.table() only returns tables, added db.view(), closes #657 * Massive documentation update for db.table() Refs #656
This commit is contained in:
parent
d892d2ae49
commit
094b010fd8
6 changed files with 276 additions and 229 deletions
|
|
@ -186,6 +186,8 @@ def tables(
|
|||
if schema:
|
||||
headers.append("schema")
|
||||
|
||||
method = db.view if views else db.table
|
||||
|
||||
def _iter():
|
||||
if views:
|
||||
items = db.view_names()
|
||||
|
|
@ -194,15 +196,15 @@ def tables(
|
|||
for name in items:
|
||||
row = [name]
|
||||
if counts:
|
||||
row.append(db[name].count)
|
||||
row.append(method(name).count)
|
||||
if columns:
|
||||
cols = [c.name for c in db[name].columns]
|
||||
cols = [c.name for c in method(name).columns]
|
||||
if csv:
|
||||
row.append("\n".join(cols))
|
||||
else:
|
||||
row.append(cols)
|
||||
if schema:
|
||||
row.append(db[name].schema)
|
||||
row.append(method(name).schema)
|
||||
yield row
|
||||
|
||||
if table or fmt:
|
||||
|
|
@ -1693,7 +1695,7 @@ def create_view(path, view, select, ignore, replace, load_extension):
|
|||
if ignore:
|
||||
return
|
||||
elif replace:
|
||||
db[view].drop()
|
||||
db.view(view).drop()
|
||||
else:
|
||||
raise click.ClickException(
|
||||
'View "{}" already exists. Use --replace to delete and replace it.'.format(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue