Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 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>")
Ejemplo n.º 5
0
def delete_FriendTable(id, FID):
    db.update("delete from " + "F" + str(id) + " where ID = ?", FID)
Ejemplo n.º 6
0
def create_FriendTable(id):
    FriendTable = Friend_Table(id)
    db.update('drop table if exists %s' % FriendTable.__table__)
    db.update(FriendTable().__sql__())
Ejemplo n.º 7
0
def delete_PGTable(uid, gid):
    db.update("delete from " + "PG" + str(uid) + " where GID = ?", gid)
Ejemplo n.º 8
0
    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", "*****@*****.**")
Ejemplo n.º 9
0
def delete_GPTable(gid, uid):
    db.update("delete from " + "GP" + str(gid) + " where ID = ?", uid)
Ejemplo n.º 10
0
def create_GPTable(gid):
    GPTable = Group_has_people_Table(gid)
    db.update(GPTable().__sql__())
Ejemplo n.º 11
0
def delete_GroupTable(gid):
    db.update("delete from GroupTable where GID = ?", gid)
Ejemplo n.º 12
0
def create_ChatTable(id):
    ChatTable = Chat_Table(id)
    db.update('drop table if exists %s' % ChatTable.__table__)
    db.update(ChatTable().__sql__())
Ejemplo n.º 13
0
def delete_ListTable(id, LID):
    db.update("delete from " + "L" + str(id) + " where LID = ?", LID)
Ejemplo n.º 14
0
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()
Ejemplo n.º 15
0
    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()
Ejemplo n.º 16
0
            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()

        
Ejemplo n.º 17
0
def create_PGTable(uid):
    PGTable = People_has_groups_Table(uid)
    db.update('drop table if exists %s' % PGTable.__table__)
    db.update(PGTable().__sql__())