Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Anum Sheraz SQLAlchemy question
Créé
il y a 5 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
9 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
33 lignes
Copier tout
12 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
36 lignes
Copier tout
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
Copier
Copié
Copier
Copié
# 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)
Copier
Copié
Copier
Copié
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()
Copier
Copié
Copier
Copié
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()
Différences enregistrées
Texte d'origine
Ouvrir un fichier
import os from flask import Flask from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy class SQLAlchemy(_BaseSQLAlchemy): def apply_pool_defaults(self, app, options): super(SQLAlchemy, self).apply_pool_defaults(app, options) options["pool_pre_ping"] = True # options["pool_recycle"] = 30 # options["pool_timeout"] = 35 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 :/ DEBUG = True # SERVER_NAME = '127.0.0.1:5000' SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI_DEV') SQLALCHEMY_TRACK_MODIFICATIONS = False config = dict( dev=DevConfig, ) app = Flask(__name__, instance_relative_config=True) app.config.from_object(config['dev']) # INIT DATABASE db.init_app(app) with app.app_context(): db.create_all()
Texte modifié
Ouvrir un fichier
import os from flask import Flask 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} 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): def apply_pool_defaults(self, app, options): super(SQLAlchemy, self).apply_pool_defaults(app, options) options["pool_pre_ping"] = DevConfig.SQLALCHEMY_PRE_PING # options["pool_recycle"] = 30 # options["pool_timeout"] = 35 db = SQLAlchemy() config = dict( dev=DevConfig, ) app = Flask(__name__, instance_relative_config=True) app.config.from_object(config['dev']) # INIT DATABASE db.init_app(app) with app.app_context(): db.create_all()
Trouver la différence