1515"""
1616
1717import os
18- from types import ModuleType
1918from .version import __version__
2019
2120__author__ = "Dimitri Yatsenko, Edgar Y. Walker, and Fabian Sinz at Baylor College of Medicine"
22- __date__ = "Oct 25 , 2018"
21+ __date__ = "Nov 15 , 2018"
2322__all__ = ['__author__' , '__version__' ,
2423 'config' , 'conn' , 'kill' , 'Table' ,
2524 'Connection' , 'Heading' , 'FreeTable' , 'Not' , 'schema' ,
@@ -68,15 +67,15 @@ class key:
6867from .connection import conn , Connection
6968from .table import FreeTable , Table
7069from .user_tables import Manual , Lookup , Imported , Computed , Part
71- from .query import Not , AndList , U
70+ from .expression import Not , AndList , U
7271from .heading import Heading
7372from .schema import Schema as schema
7473from .erd import ERD
7574from .admin import set_password , kill
7675from .errors import DataJointError , DuplicateError
7776
7877
79- def create_virtual_module (module_name , schema_name , create_schema = False , create_tables = False ):
78+ def create_virtual_module (module_name , schema_name , create_schema = False , create_tables = False , connection = None ):
8079 """
8180 Creates a python module with the given name from the name of a schema on the server and
8281 automatically adds classes to it corresponding to the tables in the schema.
@@ -87,8 +86,9 @@ def create_virtual_module(module_name, schema_name, create_schema=False, create_
8786 :param create_tables: if True, module.schema can be used as the decorator for declaring new
8887 :return: the python module containing classes from the schema object and the table classes
8988 """
90- module = ModuleType (module_name )
91- _schema = schema (schema_name , create_schema = create_schema , create_tables = create_tables )
89+ import types
90+ module = types .ModuleType (module_name )
91+ _schema = schema (schema_name , create_schema = create_schema , create_tables = create_tables , connection = connection )
9292 _schema .spawn_missing_classes (context = module .__dict__ )
9393 module .__dict__ ['schema' ] = _schema
9494 return module
0 commit comments