Пример #1
0
def create(blob):
    session.add(blob)
    session.commit()
    blob_id = blob.id
    session.close()

    return blob_id
Пример #2
0
def get_all():
  res_list = []
  for user in session.query(module.User).all():
    d = {}
    d.setdefault('id', user.id)
    d.setdefault('username', user.username)
    d.setdefault('password', user.password)
    res_list.append(d)
  session.close()
  return jsonify(res_list)
Пример #3
0
def get_user_by_name_psword(username=None, password=None):
  users = []
  for user in session.query(User).filter(User.username == username).filter(User.password == password).all():
    users.append(user)
  session.close()
  if len(users) == 1:
    return users[0]
  elif len(users) > 1:
    raise RunException('count user by username and password more than one')
  else:
    raise RunException('password is wrong')
Пример #4
0
def get_blobs_by_user_id(user_id=None, type_id=None):
    sql = session.query(Blob).outerjoin(
        Sort, Blob.id == Sort.blob_id).filter(Blob.user_id == user_id)
    if not type_id == None:
        sql = sql.filter(Sort.type_id == type_id)

    result = []
    for blob in sql.group_by(Blob.id).all():
        result.append(blob)
    session.close()
    return result
Пример #5
0
def update(user):
  session.query(User).filter(User.id == user.id).update({'username':user.username, 'password':user.password})
  session.commit()
  session.close()
Пример #6
0
def update(user_id, person):
    session.query(Person).filter(Person.user_id == user_id).update(person)
    session.commit()
    session.close()
Пример #7
0
def insert_one_person(person):
    session.add(person)
    session.commit()
    session.close()
Пример #8
0
def create(sort):
    session.add(sort)
    session.commit()
    session.close()