MambuPy for ORM

ORM module of MambuPy implements communication with a Mambu database backup living at some server of your choice. Mambu lets you download its database schema, an MySQL database you can restore anywhere you want.

MambuPy ORM uses SQLAlchemy mappings. The Data Dictionary of Mambu database can be consulted here.

As all modules in MambuPy, ORM module must be configured with a read-only connection to a Mambu database backup.

How MambuPy ORM module works

Since all the module consists of SQLAlchemy mappings, you basically use it creating SQLAlchemy’s queries.

You may import each of MambuPy.orm’s modules, but also for convienience, there is MambuPy.orm.schema_mambu which in itself imports everything inside the other modules. This means every ORM mapping inside them.

All schema modules must import MambuPy.orm.schema_orm, this module holds basic SQLAlchemy global variables, such as the Base for all tables (which needs to be the same one for everyone), or a default session, created by importing any of this modules. If you need to import all schemas at once, just import MambuPy.orm.schema_mambu, which should hold them all. If, on the other hand, you want to use a specific schema module, just be careful when dependencies happen, for example if you use MambuPy.orm.schema_groups to get groups, a group can have loans, but, to get them you need to import MambuPy.orm.schema_loans too.

You can think of the schema modules structured as follows:

_images/schemas_mambupy_diagram.png

Configuration

As you may read at MambuPy.mambuconfig, ORM configuration consists of the following options:

As MambuPy.mambuconfig documentation tells, you can set these on /etc/mambupyrc, $HOME/.mambupy.rc, on an ini-format style. Home directory RC file overrides what /etc file says.

You can also set the environment variables: MAMBUPY_DBNAME, MAMBUPY_DBUSER, MAMBUPY_DBPWD, MAMBUPY_DBHOST, MAMBUPY_DBPORT and MAMBUPY_DBENG, which override what RC files say.

Examples

API Docs