SQLite3 Python Errors

Introduction

sqlite3.OperationalError: table t already exists

If, when running a script that creates a database, you got

Traceback (most recent call last): File "C:\Users\Andrei\PycharmProjects\from_csv.py", line 5, in <module> cur.execute("""CREATE TABLE t ( sqlite3.OperationalError: table t already exists

Most likely you have already run this script, and it has already created a database with the table.

As an option - find the database and delete/rename it.

sqlite3.OperationalError: near "-": syntax error

Some column contains "-" and sqlite3 cannot digest it.

Replace it with "_"

Banner image

sqlite3.OperationalError: 2 values for 4 columns

That means there are not enough question marks - add 2

VALUES (?, ?)

Replace it with

VALUES (?, ?, ?, ?)

Article author: Andrei Olegovich