diff --git a/api/tools/reset_database.py b/api/tools/reset_database.py index 123afc5..2c5e08c 100755 --- a/api/tools/reset_database.py +++ b/api/tools/reset_database.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 -import argparse import logging -import os import asyncio from obs.api.db import init_models, connect_db +from obs.api.app import app log = logging.getLogger(__name__) @@ -12,23 +11,7 @@ log = logging.getLogger(__name__) async def main(): logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(message)s") - parser = argparse.ArgumentParser( - description="clears the postgresql database and initializes the schema" - ) - - # https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING - postgres_url_default = os.environ.get("POSTGRES_URL") - parser.add_argument( - "--postgres-url", - required=postgres_url_default is None, - action="store", - help="connection string for postgres database, if set, the track result is imported there", - default=postgres_url_default, - ) - - args = parser.parse_args() - - async with connect_db(args.postgres_url): + async with connect_db(app.config.POSTGRES_URL): await init_models() log.info("Database initialized.")