-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
db_seed.py
70 lines (63 loc) · 1.59 KB
/
db_seed.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
from app import app, db
from app.models import User, Feed
app.config["DEBUG"] = True
SQLALCHEMY_ECHO = True
SQLALCHEMY_DATABASE_URI = "sqlite:///app.db"
print("\nCreating DB Tables")
try:
db.drop_all()
db.create_all()
print("Tables Created")
except Exception as e:
print(e)
print("Problem creating tables. Check DB connection parameters")
try:
user = User()
user.id = 0
user.username = "admin"
user.password = (
"$2b$12$K6WtZoPwFi8yLmu20za5E.mJiW15vYmHDYJ1jLxR9IytJrSV/x32y" # admin
)
db.session.add(user)
db.session.commit()
print("User created admin/admin")
except Exception as e:
print(e)
print("Problem in User creation")
try:
user = User()
user.id = 1
user.username = "user"
user.password = (
"$2b$12$Sr35sAoWxKuq3hY8rf6yC.LjVHDd1ZF6jgsUZYGqvS1Mt3f7S4eSy" # user
)
db.session.add(user)
db.session.commit()
print("User created user/user")
except Exception as e:
print(e)
print("Problem in User creation")
try:
feed = Feed()
feed.id = 1
feed.name = "HowToGeek"
feed.url = "https://feeds.howtogeek.com/HowToGeek"
feed.user_id = 0
db.session.add(feed)
db.session.commit()
print("Feed created")
except Exception as e:
print(e)
print("Problem in Feed creation")
try:
feed = Feed()
feed.id = 2
feed.name = "BBC-Tech"
feed.url = "http://feeds.bbci.co.uk/news/technology/rss.xml"
feed.user_id = 0
db.session.add(feed)
db.session.commit()
print("Feed created")
except Exception as e:
print(e)
print("Problem in Feed creation")