Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在使用创建表中的参数。。。(列默认值?)子句,在Python sqlite3 db api中_Python_Sqlite_Python Db Api - Fatal编程技术网

正在使用创建表中的参数。。。(列默认值?)子句,在Python sqlite3 db api中

正在使用创建表中的参数。。。(列默认值?)子句,在Python sqlite3 db api中,python,sqlite,python-db-api,Python,Sqlite,Python Db Api,我想使用python执行CREATE语句子句,使用参数替换指定某些列的默认值?(这样我就可以安全地从python类型中指定默认值) 虽然在select或类似语句中使用参数化语句时效果很好,但它似乎不起作用。例如: 正如所料: >>> list(sqlite3.connect('sensemap.sql3').cursor().execute('select ?', (101,))) [(101,)] 意外: >>> list(sqlite3.connect(

我想使用python执行CREATE语句子句,使用参数替换指定某些列的默认值?(这样我就可以安全地从python类型中指定默认值)

虽然在select或类似语句中使用参数化语句时效果很好,但它似乎不起作用。例如:

正如所料:

>>> list(sqlite3.connect('sensemap.sql3').cursor().execute('select ?', (101,)))
[(101,)]
意外:

>>> list(sqlite3.connect('sensemap.sql3').cursor().execute('select ?', (101,)))
[(101,)]
>>> sqlite3.connect('sensemap.sql3').cursor().execute('create table mytable (mycolumn default ?)', (101,))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
OperationalError: near "?": syntax error
sqlite3.connect('sensemap.sql3').cursor().execute('create table mytable(mycolumn default?),(101,) 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 操作错误:接近“?”:语法错误
为什么呢?我正在尝试的是可能的吗?

所有架构对象的原始SQL语句都存储在数据库中(请尝试
从sqlite\u master选择SQL
)。 使用如此简单的文本值,不可能记住参数值,因此
CREATE xxx
语句中不允许使用参数