sqlite3.OperationalError:不完整的输入

cclgggtu  于 2023-10-23  发布在  SQLite
关注(0)|答案(1)|浏览(143)

这是我一直收到的INSERT INTO命令的错误。

Traceback (most recent call last):
  File "C:/Users/cabca/.PyCharmCE2019.2/config/scratches/test.py", line 34, in <module>
    part43, part44, part45, part46, part47, part48, part49, part50))
TypeError: 'str' object is not callable

代码试图在后半部分调用一个字符串,但这是不可能的。我知道我不能删除(),因为这给予的值远远超过它所能接受的最大值2。

c.execute("INSERT INTO _part_table_ (part1, part2, part3, part4, part5, part6, part7, part8, part9, part10,"
        "part11, part12, part13, part14, part15, part16, part17, part18, part19, part20, part21, part22, part23,"
        "part24, part25, part26, part27, part28, part29, part30, part31, part32, part33, part34, part35, part36,"
        "part37, part38, part39, part40, part41, part42, part43, part44, part45, part46, part47,part48, part49,"
        "part50)" (part1, part2, part3, part4, part5, part6, part7, part8, part9, part10, part11, part12, part13, part14,
        part15, part16, part17, part18, part19, part20, part21, part22, part23, part24, part25, part26, part27, part28,
        part29, part30, part31, part32, part33, part34, part35, part36, part37, part38, part39, part40, part41, part42,
        part43, part44, part45, part46, part47, part48, part49, part50))
kokeuurv

kokeuurv1#

你的INSERT语句是错误的。您要找的页面不存在。举例来说:

cursor.execute(
    '''
    INSERT INTO _part_table_ (
      part1,
      part2,
      part3
    ) VALUES (?,?,?)
    ''', 
    (part1, part2, part3))

P.S.你发布的代码片段也有语法错误:在"part50)"(part1之间应该有一个逗号。

相关问题