T
T
Tayrus02019-12-27 16:30:45
Python
Tayrus0, 2019-12-27 16:30:45

Why is the table not being created in sqlite3?

import sqlite3

from sqlite3 import Error

def sql_connection():

    try:

        con = sqlite3.connect('bomberdb.db')

        return con

    except Error:

        print(Error)

def sql_table(con):

    cursorObj = con.cursor()
    cursorObj.execute("CREATE TABLE limit(id integer, count integer)")
    limit = (360560,1)
    cursorObj.execute('INSERT INTO limit(id, count) VALUES(?, ?)', limit)
    con.commit()

con = sql_connection()
sql_table(con)

Gives an error message:
Traceback (most recent call last):
  File "db.py", line 25, in <module>
    sql_table(con)
  File "db.py", line 20, in sql_table
    cursorObj.execute("CREATE TABLE limit(id integer, count integer)")
sqlite3.OperationalError: near "limit": syntax error

Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2019-12-27
@Tayrus0

Reserved word - correct for limits - will work
https://www.w3schools.com/sql/sql_ref_keywords.asp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question