One reason might be running the code in a path that doesn't match with your specified path for the database. For example if in your code you have:
conn = lite.connect('folder_A/my_database.db')
And you run the code inside the folder_A
or other places that doesn't have a folder_A
it will raise such error. The reason is that SQLite will create the database file if it doesn't exist not the folder.
One other way for getting around this problem might be wrapping your connecting command in a try-except
expression and creating the directory if it raises sqlite3.OperationalError
.
from os import mkdir import sqlite3 as lite
try:
conn = lite.connect('folder_A/my_database.db')
except lite.OperationalError:
mkdir('folder_A')
finally:
conn = lite.connect('folder_A/my_database.db')