【发布时间】:2019-03-22 17:30:22
【问题描述】:
我正在尝试使用? 来允许我设置任意列名。
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
但我收到以下错误。所以建表时不能使用??
Traceback (most recent call last):
File "/tmp/main1.py", line 10, in <module>
c.execute("create table mytab (? text, ? real)", ('v1', 'v2'))
sqlite3.OperationalError: near "?": syntax error
【问题讨论】:
-
Variable table name in sqlite 的可能重复项(表/列名称与问题相关)