Comparing sensitive data, confidential files or internal emails?

Most legal and privacy policies prohibit uploading sensitive data online. Diffchecker Desktop ensures your confidential information never leaves your computer. Work offline and compare documents securely.

Anum Sheraz SQLAlchemy question

Created Diff never expires
9 removals
33 lines
12 additions
36 lines
import os
import os
from flask import Flask
from flask import Flask
from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy
from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy


# Coordinate DevConfig with SQLAlchemy and Flask-SQLAlchemy (don't repeat yourself!)

class DevConfig():
SQLALCHEMY_POOL_RECYCLE = 40
SQLALCHEMY_POOL_TIMEOUT = 10
SQLALCHEMY_PRE_PING = True
SQLALCHEMY_ENGINE_OPTIONS = {'pool_recycle': SQLALCHEMY_POOL_RECYCLE, 'pool_timeout': SQLALCHEMY_POOL_TIMEOUT, 'pool_pre_ping': SQLALCHEMY_PRE_PING}
Text moved from lines 18-21
DEBUG = True
# SERVER_NAME = '127.0.0.1:5000'
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI_DEV')
SQLALCHEMY_TRACK_MODIFICATIONS = False


class SQLAlchemy(_BaseSQLAlchemy):
class SQLAlchemy(_BaseSQLAlchemy):
def apply_pool_defaults(self, app, options):
def apply_pool_defaults(self, app, options):
super(SQLAlchemy, self).apply_pool_defaults(app, options)
super(SQLAlchemy, self).apply_pool_defaults(app, options)
options["pool_pre_ping"] = True
options["pool_pre_ping"] = DevConfig.SQLALCHEMY_PRE_PING
# options["pool_recycle"] = 30
# options["pool_recycle"] = 30
# options["pool_timeout"] = 35
# options["pool_timeout"] = 35


db = SQLAlchemy()
db = SQLAlchemy()



class DevConfig():
SQLALCHEMY_ENGINE_OPTIONS = {'pool_recycle': 280, 'pool_timeout': 100, 'pool_pre_ping': True} # These configs doesn't get applied in engine configs :/
Text moved to lines 12-15
DEBUG = True
# SERVER_NAME = '127.0.0.1:5000'
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI_DEV')
SQLALCHEMY_TRACK_MODIFICATIONS = False

config = dict(
config = dict(
dev=DevConfig,
dev=DevConfig,
)
)


app = Flask(__name__, instance_relative_config=True)
app = Flask(__name__, instance_relative_config=True)
app.config.from_object(config['dev'])
app.config.from_object(config['dev'])


# INIT DATABASE
# INIT DATABASE
db.init_app(app)
db.init_app(app)
with app.app_context():
with app.app_context():
db.create_all()
db.create_all()