'This method is called before engine creation and used to inject
driver specific hacks into the options.  The `options` parameter is
a dictionary of keyword arguments that will then be used to call
the :func:`sqlalchemy.create_engine` function.
The default implementation provides some saner defaults for things
like pool sizes for MySQL and sqlite.  Also it injects the setting of
`SQLALCHEMY_NATIVE_UNICODE`.'

def apply_driver_hacks(self, app, info, options):

    if info.drivername.startswith('mysql'):
        info.query.setdefault('charset', 'utf8')
        if (info.drivername != 'mysql+gaerdbms'):
            options.setdefault('pool_size', 10)
            options.setdefault('pool_recycle', 7200)
    elif (info.drivername == 'sqlite'):
        pool_size = options.get('pool_size')
        detected_in_memory = False
        if (info.database in (None, '', ':memory:')):
            detected_in_memory = True
            from sqlalchemy.pool import StaticPool
            options['poolclass'] = StaticPool
            if ('connect_args' not in options):
                options['connect_args'] = {}
            options['connect_args']['check_same_thread'] = False
            if (pool_size == 0):
                raise RuntimeError('SQLite    in    memory    database    with    an    empty    queue    not    possible    due    to    data    loss.')
        elif (not pool_size):
            from sqlalchemy.pool import NullPool
            options['poolclass'] = NullPool
        if (not detected_in_memory):
            info.database = os.path.join(app.root_path, info.database)
    unu = app.config['SQLALCHEMY_NATIVE_UNICODE']
    if (unu is None):
        unu = self.use_native_unicode
    if (not unu):
        options['use_native_unicode'] = False
