-
Notifications
You must be signed in to change notification settings - Fork 0
/
investorsDB.py
85 lines (71 loc) · 1.91 KB
/
investorsDB.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import mysql.connector
db = mysql.connector.connect(user='itc6107', password='itc6107', host='127.0.0.1');
cursor = db.cursor()
cursor.execute(
"""
DROP DATABASE IF EXISTS InvestorsDB;
CREATE DATABASE InvestorsDB;
USE InvestorsDB;
CREATE TABLE Investors (
id CHAR(20) NOT NULL primary key,
Name CHAR(20),
City CHAR(20)
);
CREATE TABLE Portfolios (
id CHAR(20) NOT NULL primary key,
Name CHAR(20),
Cumulative TINYINT(1) NOT NULL
);
CREATE TABLE Investors_Portfolios (
iid CHAR(20),
FOREIGN KEY (iid) REFERENCES Investors(id),
pid CHAR(20),
FOREIGN KEY (pid) REFERENCES Portfolios(id),
PRIMARY KEY(iid,pid)
);
CREATE TABLE Inv1_P11 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
CREATE TABLE Inv1_P12 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
CREATE TABLE Inv2_P21 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
CREATE TABLE Inv2_P22 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
CREATE TABLE Inv3_P31 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
CREATE TABLE Inv3_P32 (
id INT AUTO_INCREMENT PRIMARY KEY,
Evaluation DOUBLE,
Difference DOUBLE,
Percentage DOUBLE,
Timestamp TIMESTAMP
);
"""
)
cursor.close()
db.close()