Skip to content
Advertisement

Sqlite3 Python: can’t use “limit” as column name

There are 6 columns and for some reason when my program gets to this bit of code during install, it simply creates a blank file with no table.

Through trial and error, I found the only thing that did not create a blank file was removing the limit row.

I have other code that runs and looks the same just for different databases and it works fine.

Advertisement

Answer

“limit” is an SQL keyword, for example, as in

If you want to use “limit” as a column name in sqlite, it needs to be quoted, in one of these ways:

  • ‘limit’
  • “limit”
  • [limit]
  • `limit`

So for example, your statement could be

Note that it must be quoted in other statements too, for example

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement