move kafka to threadings and setup database connection
This commit is contained in:
@@ -3,6 +3,7 @@ from flask_cors import CORS
|
||||
from app.config import Config
|
||||
from app.routes import auth_bp, autocall_bp
|
||||
from app.errors import method_not_allowed, unsupported_media_type
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
def create_app():
|
||||
@@ -23,4 +24,7 @@ def create_app():
|
||||
app.register_error_handler(405, method_not_allowed)
|
||||
app.register_error_handler(415, unsupported_media_type)
|
||||
|
||||
# Database
|
||||
db.init_app(app)
|
||||
|
||||
return app
|
||||
|
||||
@@ -28,5 +28,15 @@ class Config:
|
||||
"BANK_CALL_BASIC_AUTH_PASSWORD", "password"
|
||||
)
|
||||
|
||||
DATABASE_USER = os.getenv("DATABASE_USER")
|
||||
DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD")
|
||||
DATABASE_HOST = os.getenv("DATABASE_HOST")
|
||||
DATABASE_NAME = os.getenv("DATABASE_NAME")
|
||||
DATABASE_PORT = os.getenv("DATABASE_PORT", 10532)
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DATABASE_USER}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}"
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
|
||||
|
||||
settings = Config()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
Reference in New Issue
Block a user