def nologging_route(model, version, elements): tables, constraints, indexes = False, False, False if elements in ['tables', 'all']: tables = True if elements in ['constraints', 'all']: constraints = True if elements in ['indexes', 'all']: indexes = True ddl_str = ddl.generate(model, version, 'oracle', tables=tables, constraints=constraints, indexes=indexes, nologging=True, service=app.config['service']) resp = Response(ddl_str, status='200 OK', mimetype='text/plain') return resp
def delete_route(model, version, dialect): ddl_str = ddl.generate(model, version, dialect, delete_data=True, service=app.config['service']) resp = Response(ddl_str, status='200 OK', mimetype='text/plain') return resp
def drop_route(model, version, dialect, elements): tables, constraints, indexes = False, False, False if elements in ['tables', 'all']: tables = True if elements in ['constraints', 'all']: constraints = True if elements in ['indexes', 'all']: indexes = True ddl_str = ddl.generate(model, version, dialect, tables=tables, constraints=constraints, indexes=indexes, drop=True, service=app.config['service']) resp = Response(ddl_str, status='200 OK', mimetype='text/plain') return resp
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'])
def test_nologging_noindexes(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', nologging=True, indexes=False) ok_(ddl_output)
def test_logging_notables(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', logging=True, tables=False) ok_(ddl_output)
def test_nologging_all(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', nologging=True) ok_(ddl_output)
def test_delete(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', delete_data=True) ok_(ddl_output)
def test_drop_noindexes(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', indexes=False, drop=True, service=SERVICE) ok_(ddl_output)
def test_drop_noconstraints(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', constraints=False, drop=True, service=SERVICE) ok_(ddl_output)
def test_notables(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', tables=False, service=SERVICE) ok_(ddl_output)
def test_drop_all(): ddl_output = ddl.generate('omop', '5.0.0', 'sqlite', drop=True, service=SERVICE) ok_(ddl_output)