Rename api to quotes-api and switch sqlite DB to WAL mode

master
Nikola Forró 6 years ago
parent 9c7459715d
commit 1dc1025820

@ -1,3 +1,4 @@
import logging
import os import os
import flask import flask
@ -7,17 +8,25 @@ import flask_restful.fields
import flask_restful.reqparse import flask_restful.reqparse
import itsdangerous import itsdangerous
import sqlalchemy import sqlalchemy
import sqlalchemy.engine
from db import db, Quote from db import db, Quote
app = flask.Flask(__name__) app = flask.Flask(__name__)
app.logger.setLevel(logging.INFO)
app.config.update( app.config.update(
ERROR_404_HELP=False, ERROR_404_HELP=False,
SQLALCHEMY_TRACK_MODIFICATIONS=False, SQLALCHEMY_TRACK_MODIFICATIONS=False,
SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI'), SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI'),
SECRET_KEY=os.getenv('SECRET_KEY')) SECRET_KEY=os.getenv('SECRET_KEY'))
if app.config.get('SQLALCHEMY_DATABASE_URI', '').startswith('sqlite://'):
@sqlalchemy.event.listens_for(sqlalchemy.engine.Engine, 'connect')
def set_sqlite_pragma(dbapi_connection, connection_record):
dbapi_connection.execute('PRAGMA journal_mode=WAL')
dbapi_connection.execute('PRAGMA synchronous=NORMAL')
db.init_app(app) db.init_app(app)
db.create_all(app=app) db.create_all(app=app)
Loading…
Cancel
Save