【问题标题】:Incorrect Syntax near ',', Expecting ID, QUOTED_ID, STRING, or TEXT_LEX','、期望 ID、QUOTED_ID、STRING 或 TEXT_LEX 附近的语法不正确
【发布时间】:2018-03-17 09:51:46
【问题描述】:

这是一个文件schema.sql,我在 Flask 上使用 SQLite 进行编码。我在自动增量旁边的逗号上收到一条语法错误消息。我想知道这有什么问题。

drop table if exists entries;

create table entries 
(
    id     integer primary key autoincrement,
    title  text not null,
    'text' text not null
);

[这是 schema.sql 的图像]

其实我不知道怎么检查sql文件的错误,因为我刚开始通过教程“Flask”学习sqlite。

http://flask.pocoo.org/docs/0.12/tutorial/schema/#tutorial-schema

这是我学习的网页。

我使用 Vscode 作为我的编辑器,当我将鼠标光标悬停在上面有红线的逗号上时,我看到了这条消息。

【问题讨论】:

  • 显示实际的错误信息。

标签: python sqlite flask


【解决方案1】:

我在 SQLite 中尝试过您的查询;查询本身似乎工作得很好。

$ sqlite3 foo.sqlite
SQLite version 3.19.3 2017-06-27 16:48:08
Enter ".help" for usage hints.
sqlite> drop table if exists entries;
sqlite> create table entries ( id integer primary key autoincrement, title text not null, 'text' text not null );
sqlite> .schema entries
CREATE TABLE entries ( id integer primary key autoincrement, title text not null, 'text' text not null );
sqlite> INSERT INTO entries (title, 'text') VALUES ('foo-title', 'foo-text');
sqlite> SELECT * FROM entries;
1|foo-title|foo-text
sqlite> ^D
$

也许错误在别处。

【讨论】:

    猜你喜欢
    • 2020-05-23
    • 2021-12-10
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2015-12-12
    相关资源
    最近更新 更多