-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.py
More file actions
42 lines (36 loc) · 923 Bytes
/
schema.py
File metadata and controls
42 lines (36 loc) · 923 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
42
#!/usr/bin/env python3
import sqlite3
connection = sqlite3.connect('master.db', check_same_thread=False)
cursor = connection.cursor()
cursor.execute(
"""CREATE TABLE users(
pk INTEGER PRIMARY KEY AUTOINCREMENT,
firstname VARCHAR(32),
lastname VARCHAR(32),
username VARCHAR(32),
password VARCHAR(32),
balance FLOAT
);"""
)
cursor.execute(
"""CREATE TABLE positions(
pk INTEGER PRIMARY KEY AUTOINCREMENT,
ticker_symbol VARCHAR,
number_of_shares INTEGER,
vwap FLOAT
);"""
)
cursor.execute(
"""CREATE TABLE transactions(
pk INTEGER PRIMARY KEY AUTOINCREMENT,
fk INTEGER,
unix_time FLOAT,
transaction_type BOOL,
last_price FLOAT,
trade_volume INTEGER,
ticker_symbol VARCHAR,
FOREIGN KEY(fk) REFERENCES users(pk)
);"""
)
cursor.close()
connection.close()