def adduser(**kwargs): name = kwargs['name'] pwd = kwargs['pwd'] user = User(name=name, pwd=pwd) user.people = People(name=name) session = getsession() session.add(user) session.commit() session.close()
def getuser(**kwargs): name = kwargs.get('name') pwd = kwargs.get('pwd') all = kwargs.get('all') session = getsession() query = session.query(User) conditioned = False if (all): return query.all() if (name != None and pwd != None): query = query.filter(and_(User.name == name, User.pwd == pwd)) conditioned = True if (conditioned): return query.all() else: return []
def checkmeeting(meeting): session = getsession() if (time2timestamp(paramdecode(meeting.begin_time)) > time2timestamp( paramdecode(meeting.end_time))): return genret(1, msg='begin_time > end_time') meetings = session.query(Meeting).filter( Meeting.room_id == meeting.room_id, ).filter( or_( and_(Meeting.begin_time <= meeting.begin_time, Meeting.end_time > meeting.begin_time), and_(Meeting.begin_time < meeting.end_time, Meeting.end_time > meeting.end_time), and_(Meeting.begin_time >= meeting.begin_time, Meeting.end_time < meeting.end_time), )).all() if len(meetings) > 0: return genret(2, msg='meeting\' s checking not pass') else: return genret(0)
def addroom(room): session = getsession() session.add(room) session.commit()
def getmeetings(): session = getsession() data = session.query(Meeting).all() return genret(0, data=data)
def addmeeting(meeting): session = getsession() session.add(meeting) session.commit()
def getroom(): session = getsession() return session.query(Room).all()
def upduser(user): session = getsession() session.query(User).filter(User.id == user.id).update( {'logintime': user.logintime}, synchronize_session=False) session.commit() session.close()