mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 02:14:31 +02:00
sqlite-utils query - to read SQL from stdin, closes #765
This commit is contained in:
parent
353baf280d
commit
619770bf42
5 changed files with 48 additions and 0 deletions
|
|
@ -1893,7 +1893,15 @@ def query(
|
|||
sqlite-utils data.db \\
|
||||
"select * from chickens where age > :age" \\
|
||||
-p age 1
|
||||
|
||||
Pass "-" as the SQL to read the query from standard input:
|
||||
|
||||
\b
|
||||
echo "select * from chickens" | sqlite-utils data.db -
|
||||
"""
|
||||
if sql == "-":
|
||||
# Read SQL from standard input
|
||||
sql = sys.stdin.read()
|
||||
db = sqlite_utils.Database(path)
|
||||
_register_db_for_cleanup(db)
|
||||
for alias, attach_path in attach:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue