-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
41 lines (35 loc) · 966 Bytes
/
Copy pathmodels.py
File metadata and controls
41 lines (35 loc) · 966 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sqlite3
db_location = 'bookings.db'
# create the tables
def create_table():
con = sqlite3.connect(db_location)
cur = con.cursor()
# for the bookings
cur.execute("""
CREATE TABLE IF NOT EXISTS bookings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL,
booking_date TEXT NOT NULL,
time TEXT NOT NULL,
table_num INTEGER NOT NULL
);
""")
# and for the simulated login
cur.execute("""
CREATE TABLE IF NOT EXISTS admin (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user TEXT NOT NULL,
password TEXT NOT NULL
);
""")
# add the admin user
user = 'Admin'
password = 'password'
cur = con.cursor()
cur.execute("INSERT INTO admin (user, password) VALUES (?, ?)", (user, password))
con.commit()
# End the connection
con.close()
# Execute the create table function
create_table()