Backends

Besides the default Redis backend, MimicDB has SQLite and in-memory backends available. To use a different backend, pass an instance of it to the MimicDB __init__ function:

from mimicdb import MimicDB
from mimicdb.backends.sqlite import SQLite

MimicDB(backend=SQLite())

Keep in mind that the default database for the SQLite backend is an in-memory database. It, along with the in-memory backend, will be destroyed when the process finishes running. For persistent data, use Redis or a custom backend.

class mimicdb.backends.Backend

Base class for MimicDB backends. Extendable to support custom backends. A custom backend must implement each of the functions of the base class.

from mimicdb.backends import Backend

class MyAwesomeBackend(Backend):
    def __init__(self):

    etc.
class mimicdb.backends.default.Redis(*args, **kwargs)

Default backend for MimicDB. Initiated with identical parameters as redis.StrictRedis.

Parameters:*args, **kwargs (args) – StrictRedis.__init__() parameters
from mimicdb.backends.default import Redis

redis = Redis(host='localhost', port=6379, db=0)
class mimicdb.backends.sqlite.SQLite(*args, **kwargs)

SQLite backend. Pass sqlite3.connect() parameters to __init__. If no parameters are passed, :memory: is chossen as the default database.

Parameters:*args, **kwargs (args) – sqlite3.connect() parameters
from mimicdb.backends.sqlite import SQLite

sqlite = SQLite('mimicdb.db')
class mimicdb.backends.memory.Memory

In-Memory backend. A good example for building a custom backend.

from mimicdb.backends.memory import Memory

memory = Memory()