因此,假设我有一个 FTS[34] 表data
和一个常规表info
,它们由 a 绑定在一起info.ID = data.rowid
。我有一个master
代表这个连接的视图,我用它来查询整体信息。以下是CREATE TABLE
声明:
CREATE VIRTUAL TABLE data USING fts4(
Name,
Keywords,
Aliases
Description);
CREATE TABLE info (
ID INTEGER PRIMARY KEY,
-- A bunch of other columns...
);
CREATE VIEW master AS SELECT
info.ID AS ID
data.Name AS Name,
data.Keywords AS Keywords,
data.Aliases AS Aliases,
data.Description AS Description,
-- A bunch of other columns...
FROM info JOIN data ON info.ID = data.rowid;
现在我要做的是创建另一个视图,而不是从表中选择整个单元格,而是选择在表的每一列上执行data
的 SQLite片段data
函数的结果:
CREATE VIEW search AS SELECT
master.*,
snippet(data '<b>', '</b>', '...', 0) AS sn_Name,
snippet(data '<b>', '</b>', '...', 1) AS sn_Keywords,
snippet(data '<b>', '</b>', '...', 2) AS sn_Aliases,
snippet(data '<b>', '</b>', '...', 3) AS sn_Description
FROM master JOIN data ON master.ID = data.rowid;
但是,当我从 Python 中执行该语句时,我得到以下信息:
sqlite3.OperationalError: near "'<b>'": syntax error