我一直在阅读Python中的字符串格式化,连接等,并遇到了一个问题。给定一个python对象,它如何在SQLite中起作用:
for table in tables:
query = 'PRAGMA table_info(%s);' % table
results = connection.execute(query)
. . .
但这不是:
for table in tables:
query = 'PRAGMA table_info({0});'.format(table)
results = connection.execute(query)
第二个版本出错:
database error: near "(": syntax error