Skip to main content

Database Cluster Session Manager

Project description

dbcluster: Database Cluster Session Manager

Kris Hardy kris@abqsoft.com

NOTE: This code is in early beta and is under active development. Please use carefully until the code stabalizes into version 1.0 (target: May 2019)

This database engine manager manages master/slave database connections and session management. This is useful for applications which need to manage sqlalchemy database engines and sessionmakers for master/slave database clusters.

Example usage:

import sqlalchemy
from dbcluster import MasterSlaveManager
manager = MasterSlaveManager()

# Set up the master(s)
manager.append_master(
    sqlalchemy.create_engine('postgresql://127.0.0.1:5432'),
    orm=MasterSlaveManager.ORM_SQLALCHEMY
)

# Set up slaves
manager.append_slave(
    sqlalchemy.create_engine('postgresql://127.0.0.1:5433'),
    orm=MasterSlaveManager.ORM_SQLALCHEMY
)

manager.append_slave(
    sqlalchemy.create_engine('postgresql://127.0.0.1:5435'),
    orm=MasterSlaveManager.ORM_SQLALCHEMY
)

# Use the database sessions
with manager.master_session_ctx() as db_session:
    # Do something with the session ...
    db_session.commit()

with manager.slave_session_ctx() as db_session:
    # Returns a random slave session
    # Do something with the session ...
    db_session.commit()

with manager.slave_session_ctx(0) as db_session:
    # Returns a session to the first slave
    # Do something with the session ...
    db_session.commit()

Project details


Release history Release notifications

This version
History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
dbcluster-0.1-py2-none-any.whl (5.7 kB) Copy SHA256 hash SHA256 Wheel py2
dbcluster-0.1.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page