OOP concept

This commit is contained in:
derlole
2025-05-15 08:08:47 +00:00
parent 885becf0e8
commit e268f0befb
8 changed files with 204 additions and 13 deletions

View 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()