Home > Software engineering >  Python sqlite3.OperationalError: unable to open database file
Python sqlite3.OperationalError: unable to open database file

Time:05-26

I am trying to create a Database on my PC using python and SQLite 3 using the code below, however when I attempt to run I get this error

conn = sqlite3.connect('test_database')
sqlite3.OperationalError: unable to open database file

I'm quite new to this, so sorry if this is a simple mistake. Could someone tell me how i can fix this?

import sqlite3


conn = sqlite3.connect('test_database') 
c = conn.cursor()
c.execute('''
          CREATE TABLE IF NOT EXISTS bot_memory
          ([id] INTEGER PRIMARY KEY, [dateandtime] datetime, [task] varchar, [result] varchar)
          ''')
          
conn.commit()
conn.close()

CodePudding user response:

The problem was I needed to install SQLite and SQLite Studio. Then, I can create and manage the Databases on my pc.

  • Related