-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize_db.py
More file actions
24 lines (19 loc) · 842 Bytes
/
Copy pathinitialize_db.py
File metadata and controls
24 lines (19 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sqlite3
def init_db():
conn = sqlite3.connect('database.db')
cursor = conn.cursor()
# Maak de tabel 'gebruikers' als deze nog niet bestaat
cursor.execute('''CREATE TABLE IF NOT EXISTS gebruikers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
naam TEXT NOT NULL,
wachtwoord TEXT NOT NULL)''')
# Maak de tabel 'admin' als deze nog niet bestaat (optioneel, bijvoorbeeld voor later gebruik)
cursor.execute('''CREATE TABLE IF NOT EXISTS admin (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL,
wachtwoord TEXT NOT NULL)''')
conn.commit()
conn.close()
if __name__ == "__main__":
init_db()
print("Database en tabellen zijn succesvol aangemaakt!")