CLI: Move alembic imports inside the calling function

Reduces execution time of "manage.py" a bit.

An import of alembic.config takes a relatively long time and
"manage.py" by itself is slow.
pull/35/head
Fabian P. Schmidt 2016-01-29 02:38:55 +01:00
rodzic 6aec9ee35d
commit 794ab5748f
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -1,6 +1,3 @@
from alembic.config import Config
from alembic import command
from ogn.commands.dbutils import engine, session from ogn.commands.dbutils import engine, session
from ogn.model import Base, AddressOrigin from ogn.model import Base, AddressOrigin
from ogn.utils import get_ddb from ogn.utils import get_ddb
@ -14,6 +11,9 @@ manager = Manager()
def init(): def init():
"""Initialize the database.""" """Initialize the database."""
from alembic.config import Config
from alembic import command
Base.metadata.create_all(engine) Base.metadata.create_all(engine)
alembic_cfg = Config("alembic.ini") alembic_cfg = Config("alembic.ini")
command.stamp(alembic_cfg, "head") command.stamp(alembic_cfg, "head")