2024-09-02 09:02:32 +02:00
|
|
|
import sqlite3
|
2024-09-02 09:35:10 +02:00
|
|
|
import os
|
|
|
|
from flask import current_app
|
2024-09-02 09:02:32 +02:00
|
|
|
|
|
|
|
def init_db():
|
2024-09-02 09:35:10 +02:00
|
|
|
db_path = os.path.join(current_app.instance_path, 'games.db')
|
|
|
|
conn = sqlite3.connect(db_path)
|
2024-09-02 09:02:32 +02:00
|
|
|
cursor = conn.cursor()
|
2024-09-02 09:31:38 +02:00
|
|
|
|
|
|
|
# Tabelle für Spiele erstellen
|
2024-09-02 09:02:32 +02:00
|
|
|
cursor.execute('''
|
|
|
|
CREATE TABLE IF NOT EXISTS games (
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
image TEXT,
|
|
|
|
title TEXT NOT NULL,
|
|
|
|
date TEXT,
|
|
|
|
buyer TEXT,
|
|
|
|
owned BOOLEAN NOT NULL
|
|
|
|
)
|
|
|
|
''')
|
2024-09-02 09:31:38 +02:00
|
|
|
|
|
|
|
# Tabelle für Benutzer erstellen
|
|
|
|
cursor.execute('''
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
username TEXT NOT NULL UNIQUE,
|
|
|
|
password TEXT NOT NULL
|
|
|
|
)
|
|
|
|
''')
|
|
|
|
|
2024-09-02 09:02:32 +02:00
|
|
|
conn.commit()
|
|
|
|
conn.close()
|