def fun(**kwargs): app = create_app(ConfigTest(**kwargs)) with app.app_context(): ResourceDefinition.__table__.create(bind=db.engine) yield app db.session.remove() db.drop_all()
def fixture_app_scope_module(): app = create_app(ConfigTest) with app.app_context(): ResourceDefinition.__table__.create(bind=db.engine) yield app db.session.remove() db.drop_all()
import os from karp import create_app from karp.config import MariaDBConfig user = os.environ["MARIADB_USER"] passwd = os.environ["MARIADB_PASSWORD"] dbhost = os.environ["MARIADB_HOST"] dbname = os.environ["MARIADB_DATABASE"] application = create_app(MariaDBConfig(user, passwd, dbhost, dbname, True)) if __name__ == "__main__": application.run(debug=True)
def create_app(): from karp import create_app return create_app(MariaDBConfig())
from karp.database import ResourceDefinition from karp import create_app from karp.config import MariaDBConfig app = create_app(MariaDBConfig(setup_database=False)) with app.app_context(): try: entry_tables = [ resource.resource_id + "_" + str(resource.version) for resource in ResourceDefinition.query.all() ] history_tables = [ table_name + "_history" for table_name in entry_tables ] except Exception: entry_tables = [] history_tables = [] database_uri = app.config["SQLALCHEMY_DATABASE_URI"]
from dotenv import load_dotenv load_dotenv(dotenv_path=".env") from karp import create_app from karp.config import MariaDBConfig def usage(): sys.exit("""Usage: {script} <port> - run in production mode on port <port> {script} dev - run in development mode """.format(script=sys.argv[0])) USER = os.environ["MARIADB_USER"] PASSWD = os.environ["MARIADB_PASSWORD"] DBHOST = os.environ["MARIADB_HOST"] DBNAME = os.environ["MARIADB_DATABASE"] application = create_app(MariaDBConfig(USER, PASSWD, DBHOST, DBNAME, True)) if __name__ == "__main__": if len(sys.argv) > 1: if sys.argv[1].lower() == "dev": application.run(debug=True) else: usage() else: usage()