contentdb/setup.py

21 lines
428 B
Python
Raw Normal View History

2018-03-18 18:43:30 +01:00
import os, datetime
delete_db = False
if delete_db and os.path.isfile("app/data.sqlite"):
os.remove("app/data.sqlite")
if not os.path.isfile("app/data.sqlite"):
2018-03-18 19:05:53 +01:00
from app.models import *
2018-03-18 18:43:30 +01:00
print("Creating database tables...")
2018-03-18 19:05:53 +01:00
db.create_all()
2018-03-18 18:43:30 +01:00
print("Filling database...")
2018-03-18 19:05:53 +01:00
ruben = User("rubenwardy")
ruben.github_username = "rubenwardy"
db.session.add(ruben)
db.session.commit()
2018-03-18 18:43:30 +01:00
else:
print("Database already exists")