def update_UserTable_time(id): Date = trans_time(time.localtime().tm_year) + "_" + trans_time( time.localtime().tm_mon) + "_" + trans_time(time.localtime().tm_mday) Time = trans_time(time.localtime().tm_hour) + "_" + trans_time( time.localtime().tm_min) + "_" + trans_time(time.localtime().tm_sec) db.update('update UserTable set Lastdate=?, Lasttime=? where ID=?', Date, Time, id)
def change_List(id, fid, listname): lid = db.select("select LID from " + "L" + str(id) + " where Listname =?", listname)[0]["LID"] print("lid", lid) db.update( "update " + 'F' + str(id) + " set LID = " + str(lid) + " where ID=?", fid)
def pass_FriendTable(applyid, passid): nickname = find_nickname(passid) FriendTable = Friend_Table(applyid)(ID=passid, Nickname=nickname, Status="F", LID=1) FriendTable.insert() db.update("update " + 'F' + str(passid) + " set Status='F' where ID=?", applyid)
def login(self,id,password): a = db.select("select * from user where ID = ? and password = ?", id,password) if len(a)==1: self.set_current_id(id) if models.Check_Friend_Table(id)==0: m = models.New_Friend_Table(id) print m.__table__ print type(m.__table__) db.update('drop table if exists %s' % m.__table__ ) db.update(m().__sql__()) #在live中通过cookie获取好友列表 self.redirect("/live",permanent = True)#跳转到listHandler get elif len(a)==0: self.write("<html><body><script type=\"text/JavaScript\">alert(\"用户名或密码错误\"); window.history.back()</script></html>") else: self.write("<html><body><script type=\"text/JavaScript\">alert(\"系统错误\"); window.history.back()</script></html>")
def delete_FriendTable(id, FID): db.update("delete from " + "F" + str(id) + " where ID = ?", FID)
def create_FriendTable(id): FriendTable = Friend_Table(id) db.update('drop table if exists %s' % FriendTable.__table__) db.update(FriendTable().__sql__())
def delete_PGTable(uid, gid): db.update("delete from " + "PG" + str(uid) + " where GID = ?", gid)
if date1 < date2: return 0 if date1 > date2: return 1 if date1 == date2: if time1 < time2: return 0 if time1 > time2: return 1 return 0 if __name__ == '__main__': import sys reload(sys) sys.setdefaultencoding('utf-8') if raw_choose('Initialize all the table in %s?' % config.database): L = [] L.append(UserTable) # L.append(GroupTable) db.create_engine(config.database) for m in L: db.update('drop table if exists %s' % m.__table__) db.update(m().__sql__()) a = new_user(10000, "123456", "Gessii", "*****@*****.**") #中文字符加u b = new_user(10001, "123456", "Ggd", "*****@*****.**") c = new_user(10002, "123456", "Johnny", "*****@*****.**") d = new_user(10003, "123456", "Alicia", "*****@*****.**") d = new_user(10004, "123456", "Emma", "*****@*****.**")
def delete_GPTable(gid, uid): db.update("delete from " + "GP" + str(gid) + " where ID = ?", uid)
def create_GPTable(gid): GPTable = Group_has_people_Table(gid) db.update(GPTable().__sql__())
def delete_GroupTable(gid): db.update("delete from GroupTable where GID = ?", gid)
def create_ChatTable(id): ChatTable = Chat_Table(id) db.update('drop table if exists %s' % ChatTable.__table__) db.update(ChatTable().__sql__())
def delete_ListTable(id, LID): db.update("delete from " + "L" + str(id) + " where LID = ?", LID)
def create_ListTable(id): ListTable = List_Table(id) db.update('drop table if exists %s' % ListTable.__table__) db.update(ListTable().__sql__()) ListTable(LID=1, Listname=u"我的好友").insert()
return FriendTable def Check_Friend_Table(id): return db.select("select count(*) from sqlite_master where type='table' and name = ?","F"+str(id))[0]["count(*)"] def Get_Friends(id): a = db.select("select ID from %s" % 'F'+str(id)) id_list = [] for i in a: id_list.append(i["ID"]) return id_list if __name__ == '__main__': import sys reload(sys) sys.setdefaultencoding('utf-8') if raw_choose('Initialize all the table in %s?' % config.database): L = [] L.append(UserTable) #L.append(FriendTable) db.create_engine(config.database); for m in L: db.update('drop table if exists %s' % m.__table__) db.update(m().__sql__()) UserTable(ID = 10000,password = "******",nickname = u"龙傲天").insert() UserTable(ID = 10001,password = "******",nickname = u"龙傲天2").insert() #插入好友列表 b = New_Friend_Table(10000)(ID = 10001,Status = "Y") b.insert() #FriendTable(ID = 10001,Status = "Y").insert()
cls.bufferinit() if len(cls.listbuffer)==0: return None cls.lock.acquire() ans = cls.listbuffer.pop() cls.lock.release() return ans if __name__ == '__main__': import sys reload(sys) sys.setdefaultencoding('utf-8') db.create_engine('zdb.db') L = [] L.append(User) L.append(UserList) for m in L: drop = u'drop table if exists %s' % m.__table__ db.update(drop) sql = u'%s' % m().__sql__() print sql db.update(sql) L = [] L.append(UserList(spaceName='fanazhe')) L.append(UserList(spaceName='zhou-yu-chen-33-18')) for m in L: print m.__table__, m m.insert()
def create_PGTable(uid): PGTable = People_has_groups_Table(uid) db.update('drop table if exists %s' % PGTable.__table__) db.update(PGTable().__sql__())