rethinkmodel.manage - Automatic database and table creation

Automatic database initialisation tools.

This module proposes some functions to automatically create database and tables by introspecting modules. It can be used in Python, or from command line (in progress).

The way to go is th create a python script, named “manage.py” for example, that will do the job. For example:

import rethinkmodel
from rethinkmodel.manage as manage

import myproject.dataModule # this is your module

# you should configure your RethinkDB connection here
rethinkmodel.config(...)

# Check if the configured database exists
manage.check_db()

# this will introspect module to find
# each "Model" object and create tables.
# It will also create database
manage(myproject.dataModule)
rethinkmodel.manage.auto(member: Type[rethinkmodel.model.Model])[source]

Automatic database and table creation for the given type (Modelchild).

rethinkmodel.manage.check_db()[source]

Check if DB_NAME exists, or create it.

rethinkmodel.manage.introspect(modpath: str)[source]

Introspect module inside a given path.

rethinkmodel.manage.manage(mod: Any)[source]

Get all classes from given module and call “auto()” function to create table.

This function accept a module, or the module name as string.