小编Ede*_*ana的帖子

Python-Sqlite-OperationalError:在“ s”附近:语法错误

尝试向表中添加值时出现以下错误:

line 33, in insert
    c.execute("INSERT INTO {tn} (Process, Info) VALUES('{proc}', 
'{inf}')".format(tn=table_name, proc=proc, inf=content))
OperationalError: near "s": syntax error
Run Code Online (Sandbox Code Playgroud)

使用某些文本时会发生这种情况,如果我写的是常规内容,就没有问题,但是例如:

#. My item number one
#. My item number two with some more content
    and it's continuing on the second line?
#. My third item::
    Oh wait, we can put code!
#. My four item::
    No way.
.. _bottom:
    Go to top_'''
Run Code Online (Sandbox Code Playgroud)

失败了。这是我正在使用的代码:

def insert(table_name, proc, content):

    conn = sqlite3.connect(sqlite_file)
    conn.text_factory = str
    c = conn.cursor()

    c.execute("INSERT INTO {tn} (Process, …
Run Code Online (Sandbox Code Playgroud)

python sql database sqlite python-2.7

4
推荐指数
1
解决办法
2843
查看次数

标签 统计

database ×1

python ×1

python-2.7 ×1

sql ×1

sqlite ×1