Annotation of MPIWGWeb/cleanDBUp.py, revision 1.1.2.1

1.1.2.1 ! dwinter     1: """loesche alle doppelten Personeneintraege aus personal_www"""
        !             2: try:
        !             3:     import psycopg2 as psycopg
        !             4:     psyco = 2
        !             5: except:
        !             6:     import psycopg
        !             7:     psyco = 1
        !             8:     
        !             9: 
        !            10: dsn="dbname=personalwww host=xserve02a user=mysql password=e1nste1n"
        !            11: dbCon = psycopg.connect(dsn)
        !            12: db = dbCon.cursor()
        !            13: 
        !            14: #find all keys
        !            15: 
        !            16: qstr="select key from personal_www group by key"
        !            17: db.execute(qstr)
        !            18: res=db.fetchall()
        !            19: keys=[x[0] for x in res]
        !            20: print keys
        !            21: for key in keys:
        !            22:     qstr="select id,publish_the_data from personal_www where key='%s' "%key
        !            23:     db.execute(qstr)
        !            24:     res=db.fetchall()
        !            25: 
        !            26:     deleteL={} #use hash to generate an unique list of keys
        !            27:     foundPublish=None
        !            28:     for x in res:
        !            29:         if x[1]=="yes":
        !            30:             foundPublish=x[1]
        !            31:         else:
        !            32:             deleteL[x[0]]=True
        !            33:   
        !            34:     delete=deleteL.keys()
        !            35:     if (len(delete)>0) and (not foundPublish): #keiner auf publish, loesche alle bis auf den letzten 
        !            36:         del delete[-1]
        !            37:     
        !            38:     
        !            39:     for x in delete:
        !            40:         if x is not None:
        !            41:             qstr="delete from personal_www where id='%s'" %x
        !            42:         
        !            43:             print qstr
        !            44:             db.execute(qstr)
        !            45:     dbCon.commit()
        !            46:     
        !            47: 
        !            48: 
        !            49: 
        !            50: 
        !            51:       

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>