Configuration

Config Schema

The following options will be added to the config schema

SQLALCHEMY_DATABASE_URI

The database URI that should be used for the connection.

Default: 'sqlite:///:memory:'

SQLALCHEMY_ECHO

If set to True SQLAlchemy will log all the statements issued to stderr which can be useful for debugging.

Default: True

SQLALCHEMY_RECORD_QUERIES

Can be used to explicitly disable or enable query recording. Query recording automatically happens in debug or testing mode. See get_debug_queries() for more information

Default: None

SQLALCHEMY_NATIVE_UNICODE

Can be used to explicitly disable native unicode support. This is required for some database adapters (like PostgreSQL on some Ubuntu versions) when used with improper database defaults that specify encoding-less databases.

Default: None

SQLALCHEMY_POOL_SIZE

The size of the database pool. Defaults to the engine’s default (usually 5)

Default: None

SQLALCHEMY_POOL_TIMEOUT

Specifies the connection timeout for the pool. Defaults to 10.

Default: None

SQLALCHEMY_POOL_RECYCLE

Number of seconds after which a connection is automatically recycled. This is required for MySQL, which removes connections after 8 hours idle by default. Note that Flask-SQLAlchemy automatically sets this to 2 hours if MySQL is used.

Default: None

SQLALCHEMY_MAX_OVERFLOW

Controls the number of connections that can be created after the pool reached its maximum size. When those additional connections are returned to the pool, they are disconnected and discarded.

Default: None

SQLALCHEMY_TRACK_MODIFICATIONS

If set to True, Flask-SQLAlchemy will track modifications of objects and emit signals. The default is None, which enables tracking but issues a warning that it will be disabled by default in the future. This requires extra memory and should be disabled if not needed.

Default: False

Alternative Variables

Some hosting providers such as Heroku other names for config values. You can remap them using the key parameter:

factory.add_config_schema({
    'SQLALCHEMY_DATABASE_URI': {
        'type': str,
        'key': 'DATABASE_URL',
    },
})

This will use the environment variable DATABASE_URL for the value to SQLALCHEMY_DATABASE_URI.