OOP concept
This commit is contained in:
BIN
db/commands.db
BIN
db/commands.db
Binary file not shown.
25
db/init_scripts/init_user_db.py
Normal file
25
db/init_scripts/init_user_db.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
def create_user_db():
|
||||
db_path = os.path.join("db", "user.db")
|
||||
|
||||
# Stelle sicher, dass der Ordner existiert
|
||||
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
||||
|
||||
# Datenbank und Tabelle erstellen
|
||||
with sqlite3.connect(db_path) as conn:
|
||||
c = conn.cursor()
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
password TEXT NOT NULL
|
||||
)
|
||||
''')
|
||||
conn.commit()
|
||||
print(f"Datenbank erstellt unter: {db_path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
create_user_db()
|
||||
BIN
db/user.db
Normal file
BIN
db/user.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user