Skip to content

Commit 396f6d6

Browse files
author
codemaster05330
committed
Create create_database.py
1 parent 99683e7 commit 396f6d6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

create_database.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Setup and create database file
2+
3+
from monitor.models import CheckedWebsite, User
4+
5+
from monitor import db, create_app
6+
db.create_all(app=create_app())
7+
8+
app = create_app()
9+
app.app_context().push()
10+
11+
with app.app_context():
12+
# Create CheckedWebsite
13+
new_website = CheckedWebsite(website_url='https://monitor.inspiredprogrammer.com', response_code='200', response_message='OK', isdown=False)
14+
db.session.add(new_website)
15+
db.session.commit()
16+
17+
# Create User
18+
new_user = User(username='TestUser', email='test@test.com', password='123456')
19+
db.session.add(new_user)
20+
db.session.commit()

0 commit comments

Comments
 (0)