This is no longer maintained and has been superseded by datajoint-company/datajoint-docs. Please file new issues there (or help contribute!). We are currently migrating and generating new content until December 2022 after which we’ll be decomissioning and in favor of

Virtual Modules

Virtual modules provide a way to access the classes corresponding to tables in a DataJoint schema without having to create local files.

The function create_virtual_module of the dj.schema class provides access to virtual modules. It creates a python module with the given name from the name of a schema on the server, automatically adds classes to it corresponding to the tables in the schema.

The function can take several parameters:

module_name: displayed module name.

schema_name: name of the database in MySQL.

create_schema: if True, create the schema on the database server if it does not already exist; if False (default), raise an error when the schema is not found.

create_tables: if True, module.schema can be used as the decorator for declaring new classes; if False, such use will raise an error stating that the module is intend only to work with existing tables.

The function returns the Python module containing classes from the schema object with all the table classes already declared inside it.

Talk to the Community