-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_db.py
36 lines (27 loc) · 919 Bytes
/
init_db.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
# init_db.py
from sqlalchemy import create_engine, MetaData
from db import users, events, cars, friends, event_users
import hashlib
db_url = "sqlite:///pooldb.db"
def create_tables(engine):
meta = MetaData()
meta.create_all(bind=engine, tables=[users, events, cars, friends, event_users])
def sample_data(engine):
conn = engine.connect()
conn.execute(users.insert(), [
{'name': 'Harris Mirza',
'lat': 51.371122,
'lng': -0.258707,
'email': "[email protected]",
'password': hashlib.sha256(b'password').hexdigest()},
{'name': 'Danial Mirza',
'lat': 51.371122,
'lng': -0.258707,
'email': "[email protected]",
'password': hashlib.sha256(b'password').hexdigest()}
])
conn.close()
if __name__ == '__main__':
engine = create_engine(db_url)
create_tables(engine)
sample_data(engine)