Skip to content

Commit

Permalink
Removing hardcoding in dbconn.py model
Browse files Browse the repository at this point in the history
Reading database URI from abstract config instead of hardcoding config setting name in method; think about creating BaseModel&Metaclass instead of sharing db and using separate model for it -> coleifer/flask-peewee#103
  • Loading branch information
Евгений Грозных authored and Евгений Грозных committed Sep 23, 2020
1 parent ec974f0 commit 701b593
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions models/dbconn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from flask import Flask
from cfg.config import DATABASE_URI
from sqlalchemy.exc import OperationalError as SQLAlchemyOperationalError
from models.logger import log_db_connection_error_and_reraise
import os

class DatabaseContext:
def setupApplicationDatabase(app:Flask):
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
def setupApplicationDatabase(app:Flask, config):
app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri']
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

def initializeDatabaseAndCreateTables(database, app:Flask):
Expand Down

0 comments on commit 701b593

Please sign in to comment.