[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.218.1.38: ~ $
"""
Support for using a dedicated read-slave. The read database is specified as a
Model.Meta option, and will be used for SELECT statements:


master = PostgresqlDatabase('master')
read_slave = PostgresqlDatabase('read_slave')

class BaseModel(ReadSlaveModel):
    class Meta:
        database = master
        read_slaves = [read_slave]  # This database will be used for SELECTs.


# Now define your models as you would normally.
class User(BaseModel):
    username = CharField()

# To force a SELECT on the master database, you can instantiate the SelectQuery
# by hand:
master_select = SelectQuery(User).where(...)
"""
from peewee import *


class ReadSlaveModel(Model):
    @classmethod
    def _get_read_database(cls):
        if not getattr(cls._meta, 'read_slaves', None):
            return cls._meta.database
        current_idx = getattr(cls, '_read_slave_idx', -1)
        cls._read_slave_idx = (current_idx + 1) % len(cls._meta.read_slaves)
        return cls._meta.read_slaves[cls._read_slave_idx]

    @classmethod
    def select(cls, *args, **kwargs):
        query = super(ReadSlaveModel, cls).select(*args, **kwargs)
        query.database = cls._get_read_database()
        return query

    @classmethod
    def raw(cls, *args, **kwargs):
        query = super(ReadSlaveModel, cls).raw(*args, **kwargs)
        if query._sql.lower().startswith('select'):
            query.database = cls._get_read_database()
        return query

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 0 B 0644
_speedups.cpython-38-x86_64-linux-gnu.so File 239.53 KB 0755
_sqlite_ext.cpython-38-x86_64-linux-gnu.so File 72.59 KB 0755
_sqlite_udf.cpython-38-x86_64-linux-gnu.so File 88.42 KB 0755
apsw_ext.py File 4.94 KB 0644
berkeleydb.py File 4.04 KB 0644
csv_loader.py File 75 B 0644
csv_utils.py File 11.34 KB 0644
dataset.py File 10.74 KB 0644
db_url.py File 3.8 KB 0644
djpeewee.py File 7.72 KB 0644
fields.py File 11.53 KB 0644
flask_utils.py File 5.53 KB 0644
gfk.py File 5.89 KB 0644
hybrid.py File 1.44 KB 0644
kv.py File 4.69 KB 0644
migrate.py File 23.49 KB 0644
pool.py File 8.01 KB 0644
postgres_ext.py File 13.13 KB 0644
read_slave.py File 1.42 KB 0644
reflection.py File 21.33 KB 0644
shortcuts.py File 7.03 KB 0644
signals.py File 2.2 KB 0644
sqlcipher_ext.py File 4.12 KB 0644
sqlite_ext.py File 34.94 KB 0644
sqlite_udf.py File 13.26 KB 0644
sqliteq.py File 8.34 KB 0644
test_utils.py File 2.73 KB 0644