-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-db
executable file
·39 lines (35 loc) · 986 Bytes
/
create-db
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
#!/usr/bin/env python3
import bcrypt
from datetime import datetime
import pytz
from app import db, User, QueuedPaper, ReadPaper
db.create_all()
timestamp = datetime.now(pytz.timezone('America/Los_Angeles'))
# Add user first to create the user ID
u1 = User(
username='user',
password_hash = bcrypt.hashpw('testpassword'.encode(), bcrypt.gensalt()))
db.session.add(u1)
db.session.commit()
# Now add papers
q1 = QueuedPaper(
user_id = u1.id,
authors='Alice',
title='Towards Being Alice',
venue='ICML',
year=1994,
priority=0,
url='https://icons.getbootstrap.com/icons/book/')
r1 = ReadPaper(
user_id = u1.id,
authors='Bob',
title='Bobology',
venue='ACL',
year=2004,
date_added=timestamp,
status=2,
url='https://icons.getbootstrap.com/icons/link/',
note='This is about Bobology.')
db.session.add(q1)
db.session.add(r1)
db.session.commit()