Files
CDRM-Bot/helper_scripts/DB_Cache/create_database.py
2023-11-17 00:52:41 -05:00

21 lines
721 B
Python

# import dependencies
import sqlite3
import os
# Check to see if the database already exists, if not create a keys folder, and create the database.
def create_database():
# Check to see if the "keys" directory exists, if not creates it
if "keys" not in os.listdir():
os.makedirs('keys')
# Change to the keys directory
os.chdir("keys")
# Check to see if a database exists in keys directory, if not create it
if not os.path.isfile("database.db"):
dbconnection = sqlite3.connect("database.db")
dbcursor = dbconnection.cursor()
dbcursor.execute('CREATE TABLE IF NOT EXISTS "DATABASE" ( "pssh" TEXT, "keys" TEXT, PRIMARY KEY("pssh") )')
dbconnection.close()