>>> import sqlite3
>>> conn = sqlite3.connect('mydb.db')
>>> cursor = conn.cursor()
>>> cursor.execute("INSERT INTO employee (emp_name, emp_dept) VALUES (?, ?)", ('Sam', 'Finance'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no such table: employee
You may get the "OperationalError - no such table" error, when working with a SQL table with SQLite database in Python for the below reasons.
- Make sure that the table you are trying to access does exist.
- Make sure that you are not creating a new database (if the DB location is incorrect) thus the table does not exist.
Fix for OperationalError - no such table
- Create the table in your SQLite database before you can perform operations on it.
- If the database and the table already exist, make sure you are within the relative path where the database is.

We can know more about the OperationalError by taking a look at "PEP-249 – Python Database API Specification v2.0"
OperationalError error is a sub-class of DatabaseError Exception which is raised when there are errors that are related to the database’s operation. These exceptions are not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc.
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Python,
- Python: Convert Date to DateTime
- How to sort a List using Lambda in Python
- Python matplotlib segmentation fault: 11 macOS Big Sur
- What is Terminal Velocity and its Formula? How to calculate it programmatically?
- How to install Python 3.11 on Mac
- How to flatten a nested list in Python
- Python: Pandas Merge DataFrames on Index Example
- How to Run all Cells at Once Jupyter Notebook
- Python - Convert float to String
- How to add borders to tkinter label text
- How to Exit a Loop in Python Code
- [Python] Fix: ValueError: All arrays must be of the same length
- Sorting an array using Bubble Sort in Python Programming
- How to Unzip a file using Python
- Python: Merge DataFrames Pandas Outer Join Example
- Change label (text) color in tkinter
- Convert Float to String in Python
- Fix: fatal error: No such file or directory compilation terminated
- Python: Access index/counter of a for loop iteration
- Import Other Python Files Examples
- How to install Anaconda on Mac (M1/M2 Mac)
- Python Regular Expression to Find All Matches in List
- How to Read a binary File with Python
- How to disable warnings while Python file execution
- Know current Python Version
More Posts:
- Installing Android Studio Dolphin on Mac with Apple (M1/M2) Chip - Android-Studio
- Lost your iPhone? Regenerate QR Code for Microsoft Authenticator App - Microsoft
- Import Other Python Files Examples - Python
- How to send WhatsApp message from your Android App using Intent - WhatsApp
- How to Add Brew to PATH M1/M2 Mac - MacOS
- How to Whitelist IP Address on GoDaddy Hosting? - HowTos
- BSNL Broadband upgrades speed to minimum 2MBps for all users 512Kbps 1Mbps - HowTos
- Setting Java_Home Environment variable on Windows Operating System - Java