Esempio n. 1
0
def main_engine(pool_size=DB_POOL_SIZE, max_overflow=5):
    engine = create_engine(db_uri(),
                           listeners=[ForceStrictMode()],
                           isolation_level='READ COMMITTED',
                           echo=False,
                           pool_size=pool_size,
                           max_overflow=max_overflow,
                           connect_args={'charset': 'utf8mb4'})
    return engine
Esempio n. 2
0
from sqlalchemy import create_engine

from inbox.sqlalchemy_ext.util import ForceStrictMode
from inbox.config import db_uri

engine = create_engine(db_uri(),
                       listeners=[ForceStrictMode()],
                       isolation_level='READ COMMITTED',
                       echo=False,
                       pool_size=25,
                       max_overflow=10,
                       connect_args={'charset': 'utf8mb4'})


def init_db():
    """ Make the tables.

    This is called only from bin/create-db, which is run during setup.
    Previously we allowed this to run everytime on startup, which broke some
    alembic revisions by creating new tables before a migration was run.
    From now on, we should ony be creating tables+columns via SQLalchemy *once*
    and all subscequent changes done via migration scripts.
    """
    from inbox.models.base import MailSyncBase

    MailSyncBase.metadata.create_all(engine)