|
1 | 1 | """ |
2 | | -DataJoint for Python is a high-level programming interface for MySQL databases |
3 | | -to support data processing chains in science labs. DataJoint is built on the |
4 | | -foundation of the relational data model and prescribes a consistent method for |
5 | | -organizing, populating, and querying data. |
| 2 | +DataJoint for Python is a framework for building data piplines using MySQL databases |
| 3 | +to represent pipeline structure and bulk storage systems for large objects. |
| 4 | +DataJoint is built on the foundation of the relational data model and prescribes a |
| 5 | +consistent method for organizing, populating, and querying data. |
| 6 | +
|
| 7 | +The DataJoint data model is described in https://arxiv.org/abs/1807.11104 |
6 | 8 |
|
7 | 9 | DataJoint is free software under the LGPL License. In addition, we request |
8 | 10 | that any use of DataJoint leading to a publication be acknowledged in the publication. |
|
18 | 20 | from .version import __version__ |
19 | 21 |
|
20 | 22 | __author__ = "Dimitri Yatsenko, Edgar Y. Walker, and Fabian Sinz at Baylor College of Medicine" |
21 | | -__date__ = "July 26, 2017" |
| 23 | +__date__ = "August 24, 2018" |
22 | 24 | __all__ = ['__author__', '__version__', |
23 | 25 | 'config', 'conn', 'kill', 'BaseRelation', |
24 | 26 | 'Connection', 'Heading', 'FreeRelation', 'Not', 'schema', |
@@ -71,17 +73,19 @@ class key: |
71 | 73 | from .errors import DataJointError, DuplicateError |
72 | 74 |
|
73 | 75 |
|
74 | | -def create_virtual_module(modulename, dbname): |
| 76 | +def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False): |
75 | 77 | """ |
76 | | - Creates a python module with the given name from a database name in mysql with datajoint tables. |
77 | | - Automatically creates the classes of the appropriate tier in the module. |
| 78 | + Creates a python module with the given name from the name of a schema on the server and |
| 79 | + automatically adds classes to it corresponding to the tables in the schema. |
78 | 80 |
|
79 | | - :param modulename: desired name of the module |
80 | | - :param dbname: name of the database in mysql |
81 | | - :return: the python module |
| 81 | + :param module_name: displayed module name |
| 82 | + :param schema_name: name of the database in mysql |
| 83 | + :param create_schema: if True, create the schema on the database server |
| 84 | + :param create_tables: if True, module.schema can be used as the decorator for declaring new |
| 85 | + :return: the python module containing classes from the schema object and the table classes |
82 | 86 | """ |
83 | | - mod = ModuleType(modulename) |
84 | | - s = schema(dbname, mod.__dict__) |
85 | | - s.spawn_missing_classes() |
86 | | - mod.__dict__['schema'] = s |
87 | | - return mod |
| 87 | + module = ModuleType(module_name) |
| 88 | + _schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables) |
| 89 | + _schema.spawn_missing_classes(context=module.__dict__) |
| 90 | + module.__dict__['schema'] = _schema |
| 91 | + return module |
0 commit comments