def role_create(name, description): try: role = Roles() role.name = name role.description = description db.session.add(role) db.session.flush() db.session.commit() return role except Exception as e: raise Exception('Database operation exception')
def role_create_db(options=None): if not options['name']: return False else: res = role_exist(options['name']) if res: return False else: role = Roles() role.name = options['name'] role.description = options['description'] db.session.add(role) db.session.commit() return role.name