예제 #1
0
def data_source_create(context, values):
    data_source = m.DataSource()
    data_source.update(values)

    try:
        data_source.save()
    except db_exc.DBDuplicateEntry as e:
        raise ex.DBDuplicateEntry("Duplicate entry for DataSource: %s" %
                                  e.columns)

    return data_source
예제 #2
0
파일: api.py 프로젝트: suriya2612/sahara
def data_source_create(context, values):
    data_source = m.DataSource()
    data_source.update(values)

    session = get_session()
    with session.begin():
        try:
            data_source.save(session=session)
        except db_exc.DBDuplicateEntry as e:
            raise ex.DBDuplicateEntry(
                _("Duplicate entry for DataSource: %s") % e.columns)

    return data_source