-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·39 lines (29 loc) · 1.09 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env python
"""Manager script for running the app and utility tasks."""
import asyncio
import logging
from aio_manager import Manager
from aio_manager.commands.ext import sqlalchemy
from feature_api.app import build_application
_logger = logging.getLogger(__name__)
async def main():
"""Initialize aio_manager instace. It's an entry point function."""
logging.basicConfig(level=logging.WARNING)
app = await build_application()
manager = Manager(app)
sqlalchemy.configure_manager(
manager, app, app['declarative_base'],
url='mysql+pymysql://{usr}:{pwd}@{host}:{port}/{db}'.
format(
usr=app.config['DATABASE_USERNAME'],
pwd=app.config['DATABASE_PASSWORD'],
db=app.config['DATABASE_NAME'],
host=app.config['DATABASE_HOST'],
port=app.config['DATABASE_PORT']
)
)
_logger.info('SQLAlchemy manager extention configured.')
return manager
if __name__ == '__main__':
manager = asyncio.get_event_loop().run_until_complete(main())
manager.run()