Skip to content
Master Slave Support For PeeWee
Python Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
pwmd
tests
.gitignore
.travis.yml
README.rst
setup.cfg
setup.py

README.rst

pwmd

Master/Slave Support For PeeWee. Now only support mysql.

The source code is locate at github .

Build Status

Usage

from peewee import Model, CharField, DateField, BooleanField
from pwmd import MultiMySQLDatabase

DATABASE = {'master': 'mysql://root@localhost/test_app',
            'slaves': ['mysql://root@localhost/test_app']}
db = MultiMySQLDatabase(DATABASE)
db.connect()


class BaseModel(Model):
    class Meta:
        database = db


class Person(BaseModel):
    name = CharField()
    birthday = DateField()
    is_relative = BooleanField()

You can force use the special db:

with db.using('master'):
    pass
Something went wrong with that request. Please try again.