def db(app): _db.app = app _db.create_all() yield _db _db.drop_all()
def clean(): # Carefull this will delete the content of the databases db.drop_all() db.create_all() db.session.commit()
def create_db(): db.create_all() db.session.commit()
def register_models(app: Flask) -> None: with app.app_context(): db.create_all()
def setUp(self): db.create_all() db.session.commit()
from app import create_app from core.extensions import db import core.models as core_models app = create_app() with app.app_context(): db.session.commit() db.drop_all() db.create_all() db.session.commit() count = core_models.Counter(name='My first counter', count=10) db.session.add(count) db.session.commit()