0

因此,假设我有一个 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
4

1 回答 1

1

data'<b>'参数值之间缺少逗号。

于 2012-10-26T18:18:26.150 回答