Last active
December 24, 2023 17:16
-
-
Save dario61081/6ae953b6d5d15a100d50b57c270e41b1 to your computer and use it in GitHub Desktop.
Funciones para verificar integridad de datos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @app.before_first_request | |
# def before_first_request(): | |
# logger.debug("Verificando modelos") | |
# models = ModelBase.__subclasses__() | |
# logger.debug(f"modelos encontrados: {models}") | |
# check_models_requirements(models) | |
# def check_models_requirements(models): | |
# """Check if the models are created in the database, if not, create them.""" | |
# with repo() as db: | |
# transaction = db.get_session().begin() | |
# try: | |
# for mdl in models: | |
# logger.debug(f"checking model {mdl.__tablename__}") | |
# if not db.table_exists(mdl): | |
# db.create_table(mdl) | |
# logger.debug(f"(OK) created table {mdl.__tablename__}") | |
# else: | |
# logger.debug(f"(OK) table {mdl.__tablename__} exists") | |
# except Exception as ex: | |
# transaction.rollback() | |
# logger.error(f"error checking models {ex}") | |
# else: | |
# transaction.commit() | |
# logger.success("models checked successfully") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment