-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_maker.py
More file actions
62 lines (55 loc) · 1.22 KB
/
Copy pathdatabase_maker.py
File metadata and controls
62 lines (55 loc) · 1.22 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# this file is just make tables if they aren't exist in database
import sqlite3
def run():
data = sqlite3.connect('data.db')
cur = data.cursor()
cur.execute("""
CREATE TABLE IF NOT EXISTS places (
id integer PRIMARY KEY,
name text NOT NULL,
address text NOT NULL,
distance integer
);
""")
cur.execute("""
CREATE TABLE IF NOT EXISTS persons (
id integer PRIMARY KEY,
name text NOT NULL,
age integer,
gender text
);
""")
cur.execute("""
CREATE TABLE IF NOT EXISTS dates (
id integer PRIMARY KEY,
year integer,
month integer,
day integer,
weekday text NOT NULL
);
""")
cur.execute("""
CREATE TABLE IF NOT EXISTS payment_methods (
id integer PRIMARY KEY,
name text NOT NULL,
number text NOT NULL
);
""")
cur.execute("""
CREATE TABLE IF NOT EXISTS expenses (
id integer PRIMARY KEY,
amount integer,
explanation text,
discount integer,
place integer NOT NULL,
date integer NOT NULL,
person integer NOT NULL,
payment_method integer NOT NULL,
FOREIGN KEY (place) REFERENCES places(id),
FOREIGN KEY (date) REFERENCES dates(id),
FOREIGN KEY (person) REFERENCES persons(id),
FOREIGN KEY (payment_method) REFERENCES payment_methods(id)
);
""")
data.commit()
data.close()