google.cloud.forseti.services.db module

Database session handling for Forseti Server.

class ScopedSession(session, auto_commit=False, readonly=False)[source]

Bases: object

A scoped session is automatically released.

__enter__()[source]

To support with statement.

Returns:Returns its session.
Return type:object
__exit__(exc_type, value, traceback)[source]

To support with statement.

Parameters:
  • exc_type (object) – Exception type
  • value (object) – Exception value
  • traceback (object) – Traceback if any
class ScopedSessionMaker(session_maker, auto_commit=False)[source]

Bases: object

Wraps session maker to create scoped sessions.

__call__(*args)[source]

Creates a new session.

Parameters:*args (list) – Will be forwarded to session creator.
Returns:Scoped session.
Return type:object
_abort_readonly()[source]

Intercept the flush operation and log a warning message.

create_scoped_readonly_session(engine)[source]

Creates a readonly scoped session.

Parameters:engine (object) – Engine to bind session to.
Returns:Scoped session maker.
Return type:object
create_scoped_sessionmaker(engine)[source]

Creates a scoped session maker

Parameters:engine (object) – Engine to bind session to.
Returns:Scoped session maker.
Return type:object
stub_out_flush_operation(session)[source]

Stub out flush operation.

Parameters:session (Session) – Session to stub out.
Returns:The session after stubbed out the flush operation.
Return type:Session