예제 #1
0
파일: 002_data.py 프로젝트: xyuan/mlcomp
def upgrade(migrate_engine):
    folder = os.path.dirname(__file__)
    session = Session.create_session(connection_string=migrate_engine.url)
    provider = ReportLayoutProvider(session)

    try:
        files = os.path.join(folder, '002', 'report_layout', '*.yml')
        for path in glob(files):
            name = str(os.path.basename(path).split('.')[0])
            text = open(path).read()
            provider.add(ReportLayout(name=name,
                                      content=text,
                                      last_modified=now()),
                         commit=False)

        provider.commit()
    except Exception:
        provider.rollback()
        raise
예제 #2
0
파일: app.py 프로젝트: xang1234/mlcomp
def report_layout_add():
    data = request_data()

    provider = ReportLayoutProvider(_write_session)
    layout = ReportLayout(name=data['name'], content='', last_modified=now())
    provider.add(layout)