1

So I'm trying to create a database that will have a table which will store user IDs, usernames, and password hashes and am using PyCharm for this project. I'm a beginner and don't know much about using PyCharm and this seems to be one of the things I know almost nothing about. Here's the code:

    import sqlite3

    conn = sqlite3.connect("data.db")

    db = conn.cursor()

    sql = '''CREATE TABLE IF NOT EXISTS 'users' 
                ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 
                'username' TEXT NOT NULL, 'hash' TEXT NOT NULL)'''

    db.execute(sql)

The error I get looks like this:

  Traceback (most recent call last):
    File "C:/Users/*****/PycharmProjects/*****/sqlite.py", line 8, in <module>
      db.execute(sql)
  sqlite3.DatabaseError: file is not a database

Any help would be appreciated!

CocoaKoala
  • 29
  • 1
  • 3

1 Answers1

1

So sorry just had to create the db in the sqlite3 terminal (if you know what I mean) sorry for wasting your time.

Sqlite Error: file is not a database

CocoaKoala
  • 29
  • 1
  • 3