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 | RSS feed

This version

0.1

Download files

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

Source Distribution

dbcluster-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbcluster-0.1-py2-none-any.whl (5.7 kB view details)

Uploaded Python 2

File details

Details for the file dbcluster-0.1.tar.gz.

File metadata

  • Download URL: dbcluster-0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for dbcluster-0.1.tar.gz
Algorithm Hash digest
SHA256 83da2df141fd0db14257d43db4b4fe62f4bf15fe49eb529106029a06b459647e
MD5 6984bfdfcf39ce5698caa8ea2dfba4ae
BLAKE2b-256 bcee5113c7a240cefd1ec3d369f8319df2528a44709645a0fb60ca89a439cfd0

See more details on using hashes here.

File details

Details for the file dbcluster-0.1-py2-none-any.whl.

File metadata

  • Download URL: dbcluster-0.1-py2-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for dbcluster-0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 7414ff239be0373be0427fdb929f90a2208953533414b12604ac06a02dbbb32e
MD5 2e0fd7a3cbe57873ef66fd0591eeb492
BLAKE2b-256 c8380e85d9d7b1d3d238245f950447fae56e1f6c0de91382b662a3528cf7cb97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page