try to package...
This commit is contained in:
parent
6547bf9d9c
commit
08403e205e
@ -1,5 +1,5 @@
|
|||||||
from oshipka import init_db
|
from oshipka.persistance import init_db
|
||||||
from oshipka import app
|
from oshipka.webapp import app
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
init_db(app)
|
init_db(app)
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
|
||||||
|
from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE
|
||||||
|
from oshipka.persistance.populate import populate_db
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
|
|
||||||
|
|
||||||
|
def init_db(app):
|
||||||
|
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
|
||||||
|
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||||
|
|
||||||
|
db.init_app(app)
|
||||||
|
for dir in MAKEDIRS:
|
||||||
|
os.makedirs(dir, exist_ok=True)
|
||||||
|
if not os.path.exists(DATABASE_FILE):
|
||||||
|
with app.app_context():
|
||||||
|
db.create_all()
|
||||||
|
populate_db(app)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE
|
|
||||||
from oshipka.persistance import db
|
|
||||||
|
|
||||||
|
|
||||||
def populate_db(app):
|
def populate_db(app):
|
||||||
@ -9,14 +6,3 @@ def populate_db(app):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def init_db(app):
|
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
|
|
||||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
||||||
|
|
||||||
db.init_app(app)
|
|
||||||
for dir in MAKEDIRS:
|
|
||||||
os.makedirs(dir, exist_ok=True)
|
|
||||||
if not os.path.exists(DATABASE_FILE):
|
|
||||||
with app.app_context():
|
|
||||||
db.create_all()
|
|
||||||
populate_db(app)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user