Custom Oven Drivers — Recipe 0.5.1 documentation

# Custom Oven Drivers

It’s possible to implement your own custom oven drivers to get a desired behavior for the engine or the session. An abstract base class is provided for you to inherit from called `OvenBase`. You need to implement an `init_engine` that returns a SQLAlchemy engine, and an `init_session` that returns a SQLAlchemy sessionmaker. The default `__init__` method sets the output of both of these to to the oven’s `engine` and `Session` properties respectively.

Note

Remember to use recipe’s built in settings to handle any configuration options/settings you made need for your driver.

## OvenBase

class `recipe.oven.base.` `OvenBase`(connection_string=None)

  Base class for ovens

  `init_engine`(connection_string=None, **kwargs)

    Initializes a SQLAlchemy Engine for a given connection string with all other keyword arguments passed to the create_engine function. The connection uses pre-ping to verify connections.

    Parameters: | self (Oven) – a reference to ourselves connection_string (str) – a reference to ourselves kwargs (dict) – a collection of arguments passed to the engine
    Returns: | A SQLAlchemy Engine with connection checking
    Return type: | SQLAlchemy.Engine

  `init_session`()

    Initializes a SQLAlchemy Session with the Oven’s engine

    Parameters: | self (Oven) – a reference to ourselves
    Returns: | A SQLAlchemy Session using self.engine
    Return type: | SQLAlchemy.Session