【问题标题】:Unrecognized token in sqlite3 while creating a table创建表时sqlite3中无法识别的令牌
【发布时间】:2021-01-05 17:16:52
【问题描述】:

我知道有很多关于无法识别的令牌的解决方案,但它们都在执行 insert() 查询时出现,但在创建表时出现错误。 这是一段代码

def table_stats():
    c.execute("""CREATE TABLE stats(
            player text,
            matches real,
            runs real,
            100s real,
            50s real,
            value real,
            ctg text
        )""")
    conn.commit() 
table_stats()

sqlite3.OperationalError:无法识别的令牌:“100s” 我正在做一个简单的项目,在问题陈述的提示部分它显示了表的“100s”属性,但在我的代码中它会产生错误。

【问题讨论】:

    标签: python sql sql-insert create-table sqlite3-ruby


    【解决方案1】:

    标识符(例如列名)不能以数字开头。您可以选择其他名称(例如 hundredsnum_100s)。例如:

    CREATE TABLE stats(
        player text,
        matches real,
        runs real,
        num_100s real,
        num_50s real,
        value real,
        ctg text
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      相关资源
      最近更新 更多