0

I've been reading up on string formatting, concatenation, etc in Python and ran into an issue. Given a python object, how come this works in SQLite:

for table in tables:
    query = 'PRAGMA table_info(%s);' % table
    results = connection.execute(query)
    . . .

but this doesn't:

for table in tables:
    query = 'PRAGMA table_info({0});'.format(table)
    results = connection.execute(query)

Error for the second version:

database error: near "(": syntax error
nicorellius
  • 3,715
  • 4
  • 48
  • 79

0 Answers0