Skip to content

Commit d22adb6

Browse files
author
eshaan7
committed
create_db.py to initialize db file
1 parent 144b56e commit d22adb6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/create_db.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import datetime
2+
3+
from FlaskRTBCTF import create_app, db, bcrypt
4+
from FlaskRTBCTF.models import User, Score
5+
6+
app = create_app()
7+
8+
# create_app().app_context().push()
9+
with app.app_context():
10+
db.create_all()
11+
12+
# NOTE: CHANGE DEFAULT CREDENTIALS !!!
13+
admin_user = User(
14+
username='admin',
15+
email='admin@admin.com',
16+
password=bcrypt.generate_password_hash('admin').decode('utf-8'),
17+
confirmed_at=datetime.datetime.now(),
18+
isAdmin = True
19+
)
20+
score = Score(userid=admin_user.id, userHash=False, rootHash=False, score=0)
21+
db.session.add(admin_user)
22+
db.session.add(score)
23+
db.session.commit()

0 commit comments

Comments
 (0)