TPD-Keys/Helpers/database_check.py
TPD94 a39e10c1db TPD-Keys 2.0 Release
Cleaned up code, added remote options for all services, improved modularity
2023-12-04 04:46:41 -05:00

19 lines
753 B
Python

# Import dependencies
import os
import sqlite3
# Check to see if the database already exists, if not create a keys folder, and create the database.
def database_check():
# Check to see if the "keys" directory exists, if not creates it
if "keys" not in os.listdir(os.getcwd()):
os.makedirs('keys')
# Check to see if a database exists in keys directory, if not create it
if not os.path.isfile(f"{os.getcwd()}/keys/database.db"):
print(f"Creating database.\n")
dbconnection = sqlite3.connect(f"{os.getcwd()}/keys/database.db")
dbcursor = dbconnection.cursor()
dbcursor.execute('CREATE TABLE IF NOT EXISTS "DATABASE" ( "pssh" TEXT, "keys" TEXT, PRIMARY KEY("pssh") )')
dbconnection.close()