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)[source]

Base class for ovens

abstract init_engine(connection_string=None, **kwargs)[source]

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

abstract init_session()[source]

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