Python / sqlite:按用户输入的表名查询数据库

时间:2015-05-22 18:41:14

标签: python sqlite

在Python 3中,我试图在sqlite表上进行简单查询,用户输入表名。但是我无法将输入变量添加到查询中。部分代码如下:

choice = input ("Enter table name ")
    c.execute("SELECT * FROM ?", choice)
    print(c.fetchall())

ERRORMSG。是:

sqlite3.OperationalError: near "?": syntax error

我尝试了不同的变化,没有运气。有人知道是否有好的解决方案?

谢谢,-Espen

0 个答案:

没有答案