def main(): import sys from docopt import docopt from dmsa import __version__ # Parse command line arguments. args = docopt(__doc__, argv=sys.argv[1:], version=__version__) if args['ddl']: from dmsa import ddl output = ddl.generate(args['<model>'], args['<model_version>'], args['<dialect>'], args['--tables'], args['--constraints'], args['--indexes'], args['--drop'], args['--delete-data'], args['--nologging'], args['--logging'], args['--service']) if args['--output']: f = open(args['--output'], 'w') f.write(output) f.close() else: return sys.stdout.write(output) elif args['erd']: from dmsa import erd try: return erd.write(args['<model>'], args['<model_version>'], args['--output'], args['--service']) except ImportError: sys.stderr.write( 'ERD not supported because ERAlchemy module not installed\n') sys.exit(1) elif args['serve']: from dmsa import service app = service.build_app(args['--service']) app.run(host=args['--host'], port=int(args['--port']), debug=args['--debug'])
import os from nose.tools import eq_ from dmsa import service from dmsa.utility import get_template_models SERVICE = os.environ.get('DMSA_TEST_SERVICE', 'https://data-models-service.research.chop.edu/') app = service.build_app(SERVICE, refresh_interval=None) app.config['TESTING'] = True test_app = app.test_client() ENDPOINTS = ['/'] for m in get_template_models(SERVICE): ENDPOINTS.append('/%s/' % m['name']) for v in m['versions']: ENDPOINTS.append('/%s/%s/' % (m['name'], v['name'])) ENDPOINTS.append('/%s/%s/erd/' % (m['name'], v['name'])) ENDPOINTS.append('/%s/%s/ddl/sqlite/' % (m['name'], v['name'])) ENDPOINTS.append('/%s/%s/drop/sqlite/' % (m['name'], v['name'])) ENDPOINTS.append('/%s/%s/delete/sqlite/' % (m['name'], v['name'])) for e in ['tables', 'indexes']:
import os from nose.tools import eq_ from dmsa import service from dmsa.utility import get_template_models SERVICE = os.environ.get("DMSA_TEST_SERVICE", "https://data-models-service.research.chop.edu/") app = service.build_app(SERVICE) app.config["TESTING"] = True test_app = app.test_client() ENDPOINTS = ["/"] for m in get_template_models(SERVICE): ENDPOINTS.append("/%s/" % m["name"]) for v in m["versions"]: ENDPOINTS.append("/%s/%s/" % (m["name"], v["name"])) ENDPOINTS.append("/%s/%s/erd/" % (m["name"], v["name"])) ENDPOINTS.append("/%s/%s/ddl/sqlite/" % (m["name"], v["name"])) ENDPOINTS.append("/%s/%s/drop/sqlite/" % (m["name"], v["name"])) ENDPOINTS.append("/%s/%s/delete/sqlite/" % (m["name"], v["name"])) for e in ["tables", "indexes"]: ENDPOINTS.append("/%s/%s/ddl/sqlite/%s/" % (m["name"], v["name"], e)) ENDPOINTS.append("/%s/%s/drop/sqlite/%s/" % (m["name"], v["name"], e))