Skip to content

Commit b2078ce

Browse files
committed
Use double quotes not braces for tables and columns
Refs #677
1 parent 52ea7d2 commit b2078ce

17 files changed

+682
-609
lines changed

sqlite_utils/cli.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
import pathlib
77
from runpy import run_module
88
import sqlite_utils
9-
from sqlite_utils.db import AlterError, BadMultiValues, DescIndex, NoTable
9+
from sqlite_utils.db import (
10+
AlterError,
11+
BadMultiValues,
12+
DescIndex,
13+
NoTable,
14+
quote_identifier,
15+
)
1016
from sqlite_utils.plugins import pm, get_plugins
1117
from sqlite_utils.utils import maximize_csv_field_size_limit
1218
from sqlite_utils import recipes
@@ -1967,7 +1973,9 @@ def memory(
19671973
view_names.append("t")
19681974
for view_name in view_names:
19691975
if not db[view_name].exists():
1970-
db.create_view(view_name, "select * from [{}]".format(file_table))
1976+
db.create_view(
1977+
view_name, "select * from {}".format(quote_identifier(file_table))
1978+
)
19711979

19721980
if fp:
19731981
fp.close()
@@ -2230,8 +2238,8 @@ def rows(
22302238
"""
22312239
columns = "*"
22322240
if column:
2233-
columns = ", ".join("[{}]".format(c) for c in column)
2234-
sql = "select {} from [{}]".format(columns, dbtable)
2241+
columns = ", ".join(quote_identifier(c) for c in column)
2242+
sql = "select {} from {}".format(columns, quote_identifier(dbtable))
22352243
if where:
22362244
sql += " where " + where
22372245
if order:
@@ -2288,10 +2296,10 @@ def triggers(
22882296
\b
22892297
sqlite-utils triggers trees.db
22902298
"""
2291-
sql = "select name, tbl_name as [table], sql from sqlite_master where type = 'trigger'"
2299+
sql = "select name, tbl_name as \"table\", sql from sqlite_master where type = 'trigger'"
22922300
if tables:
22932301
quote = sqlite_utils.Database(memory=True).quote
2294-
sql += " and [table] in ({})".format(
2302+
sql += ' and "table" in ({})'.format(
22952303
", ".join(quote(table) for table in tables)
22962304
)
22972305
ctx.invoke(

0 commit comments

Comments
 (0)