Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Simple Master Slave Load Balancing

Project description

SQLAlchemy Simple Master Slave Load Balancing(*beta*)

You can install Pymysqlslave from PyPI with

$ pip install pymysqlslave

Version update

  • 1.0.6 [BUG]MySQLDBSlave open retry not avaliable
  • 1.0.5 [BUG]MySQLDBSlave slaves unavailable. modify MySQLDBSlave reconnect_retry_nums default => 3
  • 1.0.3 add is_auto_allocation(Automatic Identification master and slave)
  • 1.0.1 initialize project

Getting Started

#!/usr/bin/env python
# coding=utf-8

import logging
from sqlalchemy import select

from pymysqlslave import MySQLDBSlave

jianv1 = MySQLDBSlave(
            "name": "mysql+mysqldb://",
            "echo": False,
            "pool_size": 5,
            "pool_recycle": 1,
            "name": "mysql+mysqldb://",
            "echo": False,
            "pool_size": 5,
            "pool_recycle": 1,

def get_info_by_email(email):
    _t = jianv1.table.customer_member_t
    sql = select([_t]).where( == email)
    return jianv1.execute(sql).fetchone()

def update_info_by_email(email):
    _t = jianv1.table.customer_member_t
    sql = _t.update().where( == email).values(name=u"穿完")

if __name__ == "__main__":
    result = get_info_by_email("")


  • 根据不同的环境,用户选择不同的slave
  • add retry connecting(bug: interactive_timeout)
  • add is_auto_allocation(Automatic Identification master and slave)
  • Thread Safety


If you need help using pymysqlslave or have found a bug, please open a github issue.

Project details

Download files

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

Files for pymysqlslave, version 1.0.7
Filename, size File type Python version Upload date Hashes
Filename, size pymysqlslave-1.0.7.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page