[Answer]-Error Manually Creating Table in Django

1👍

The table name in CREATE TABLE should not be quoted. This also means it can’t be passed as a parameter (in a prepared statement in your case).

You’ll need to use regular string interpolation for it:

  c.execute("CREATE TABLE %s (<snip>)" % t_name)

You’ll have to be very careful not to introduce a SQL injection here. t_name must be properly sanitized (and that doesn’t mean quoted).

Leave a comment