Database

We support Oracle and Postgres databases.

Multiple hosts

The dsn parameter of service database config should be specified to enable multihost option for Postgres.

DSN may be specified in the following format: luna:luna@postgres01:5432,postgres02:5432/luna_streams?some_option=some_value. It is possible to partially fill in the DSN string (e.g. postgres01,postgres02/luna_streams), and then the missing parameters will be filled in from proprietary parameter values (or defaults).

At startup, the service will create a pool of connections to one of DSN hosts available. In case of problems with establishing a connection after several unsuccessful attempts, the service will again try to set up a connection pool to any of DSN hosts available.

DB scheme

_images/db.png
class luna_streams.db.streams_db_tools.models.streams_db_models.Group(**kwargs)[source]

Database table model for group.

class luna_streams.db.streams_db_tools.models.streams_db_models.GroupStream(**kwargs)[source]

Database table model for links between stream and group.

class luna_streams.db.streams_db_tools.models.streams_db_models.Handler(**kwargs)[source]

Database table model for stream handler info.

class luna_streams.db.streams_db_tools.models.streams_db_models.Location(**kwargs)[source]

Database table model for stream location info.

class luna_streams.db.streams_db_tools.models.streams_db_models.Log(**kwargs)[source]

Database table model for stream logging.

class luna_streams.db.streams_db_tools.models.streams_db_models.Restart(**kwargs)[source]

Database table model for stream restart info.

class luna_streams.db.streams_db_tools.models.streams_db_models.SingleProcessLock(**kwargs)[source]

Table for storing one-at-time process lock. Lock a needed process by selecting row with FOR UPDATE for a guaranteed single-instance execution.

class luna_streams.db.streams_db_tools.models.streams_db_models.Stream(**kwargs)[source]

Database table model for streams.

luna_streams.db.streams_db_tools.models.streams_db_models.view(name, selectable)[source]

Create a simple view object. Use it like a table: select([SomeView.c.roi]) or SomeView.insert().values(name=’foo’).

Parameters:
  • name (str) – view name

  • selectable – any selectable that has columns

Return type:

TableClause

Returns:

sa.table object (NOT Model)