mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-01 15:04:11 +02:00
sqlite-utils rows --where and -p options, closes #382
This commit is contained in:
parent
324ebc3130
commit
3b632f0a7e
4 changed files with 57 additions and 18 deletions
|
|
@ -1723,6 +1723,14 @@ def search(
|
|||
)
|
||||
@click.argument("dbtable")
|
||||
@click.option("-c", "--column", type=str, multiple=True, help="Columns to return")
|
||||
@click.option("--where", help="Optional where clause")
|
||||
@click.option(
|
||||
"-p",
|
||||
"--param",
|
||||
multiple=True,
|
||||
type=(str, str),
|
||||
help="Named :parameters for where clause",
|
||||
)
|
||||
@click.option(
|
||||
"--limit",
|
||||
type=int,
|
||||
|
|
@ -1741,6 +1749,8 @@ def rows(
|
|||
path,
|
||||
dbtable,
|
||||
column,
|
||||
where,
|
||||
param,
|
||||
limit,
|
||||
offset,
|
||||
nl,
|
||||
|
|
@ -1758,6 +1768,8 @@ def rows(
|
|||
if column:
|
||||
columns = ", ".join("[{}]".format(c) for c in column)
|
||||
sql = "select {} from [{}]".format(columns, dbtable)
|
||||
if where:
|
||||
sql += " where " + where
|
||||
if limit:
|
||||
sql += " limit {}".format(limit)
|
||||
if offset:
|
||||
|
|
@ -1773,6 +1785,7 @@ def rows(
|
|||
no_headers=no_headers,
|
||||
table=table,
|
||||
fmt=fmt,
|
||||
param=param,
|
||||
json_cols=json_cols,
|
||||
load_extension=load_extension,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue