MikaList/game_collection/database.py

30 lines
708 B
Python
Raw Normal View History

import sqlite3
def init_db():
conn = sqlite3.connect('games.db')
cursor = conn.cursor()
# Tabelle für Spiele erstellen
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
)
''')
# 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
)
''')
conn.commit()
conn.close()