Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ build-backend = "setuptools.build_meta"
max-line-length = 160
# Black compatibility, E203 whitespace before ':':
extend-ignore = ["E203"]
exclude = [".venv"]

[tool.setuptools.package-data]
sqlite_utils = ["py.typed"]
20 changes: 14 additions & 6 deletions sqlite_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import pathlib
from runpy import run_module
import sqlite_utils
from sqlite_utils.db import AlterError, BadMultiValues, DescIndex, NoTable
from sqlite_utils.db import (
AlterError,
BadMultiValues,
DescIndex,
NoTable,
quote_identifier,
)
from sqlite_utils.plugins import pm, get_plugins
from sqlite_utils.utils import maximize_csv_field_size_limit
from sqlite_utils import recipes
Expand Down Expand Up @@ -1967,7 +1973,9 @@ def memory(
view_names.append("t")
for view_name in view_names:
if not db[view_name].exists():
db.create_view(view_name, "select * from [{}]".format(file_table))
db.create_view(
view_name, "select * from {}".format(quote_identifier(file_table))
)

if fp:
fp.close()
Expand Down Expand Up @@ -2230,8 +2238,8 @@ def rows(
"""
columns = "*"
if column:
columns = ", ".join("[{}]".format(c) for c in column)
sql = "select {} from [{}]".format(columns, dbtable)
columns = ", ".join(quote_identifier(c) for c in column)
sql = "select {} from {}".format(columns, quote_identifier(dbtable))
if where:
sql += " where " + where
if order:
Expand Down Expand Up @@ -2288,10 +2296,10 @@ def triggers(
\b
sqlite-utils triggers trees.db
"""
sql = "select name, tbl_name as [table], sql from sqlite_master where type = 'trigger'"
sql = "select name, tbl_name as \"table\", sql from sqlite_master where type = 'trigger'"
if tables:
quote = sqlite_utils.Database(memory=True).quote
sql += " and [table] in ({})".format(
sql += ' and "table" in ({})'.format(
", ".join(quote(table) for table in tables)
)
ctx.invoke(
Expand Down
Loading
Loading