Problema con BD y python

javi lopez javi80mix en gmail.com
Jue Dic 21 14:39:46 CET 2006


Hola estoy haciendo un script para mi BD,  pero al ejecutarlo, siempre
me copia el ultimo comentario, no me va recorriendo desde el primero
al ultimo y no se que voy haciendo mal.Este es el codigo.Gracias por
vuestra ayuda.

cursor.execute("select * from BD limit 5")
    filas = cursor.fetchall()
    for row in filas:
      if (row[1]!=0):
            topicID = row[2]
            PostID = row[0]
            UIDcreation = "Javi"#row[5]
            UIDmodifying = "Javi"#row[5]
            ip = row[6]
            cursor.execute("INSERT INTO zf_posts (topic_id,
creation_user, modifying_user, ip_address) values
('%d','%s','%s','%s')" % (topicID, UIDcreation, UIDmodifying, ip))
            cursor.execute("SELECT post_text FROM xoops_bb_posts_text
WHERE post_id = %d" % (PostID))
            cursor.execute("UPDATE zf_posts SET creation_date = now(),
modifying_date = now()")
            cursor.execute("UPDATE zf_posts SET content = '%s'" %
(unicode(cadena,'latin-1')))
      else:
            topicID = row[2]
            UIDcreation = "Javi"#row[5]
            UIDmodifying = "Javi"#row[5]
            ip = row[6]
            forumid = row[3]
            title= unicode(row[7],'latin-1')
            creationUser= "Javi"#row[5]
            topicFirstIP= row[5]
            topicLastIP= row[5]
            PostID = row[0]

            cursor.execute("INSERT INTO zf_topics (forum_id,
topic_title, creation_user, topic_first_post_id, topic_last_post_id)
values ('%d','%s','%s','%d','%d')" % (forumid, title, creationUser,
topicFirstIP, topicLastIP))
            cursor.execute("UPDATE zf_topics SET creation_date =
now(), topic_views = 0, topic_replies = 0, locked_flag = 0,
disabled_flag = 0, sticky_flag = 0, poll_flag = 0,
system_announcement_flag = 0")
            cursor.execute("INSERT INTO zf_posts (topic_id,
creation_user, modifying_user, ip_address) values
('%d','%s','%s','%s')" % (topicID, UIDcreation, UIDmodifying, ip))
            cursor.execute("UPDATE zf_posts, xoops_bb_posts_text SET
zf_posts.content = xoops_bb_posts_text.post_text where
xoops_bb_posts_text.post_id = ('%d') " % (PostID))
            cursor.execute("UPDATE zf_posts SET creation_date = now(),
modifying_date = now()")

            cursor.execute("SELECT post_text FROM xoops_bb_posts_text
WHERE post_id = %d" % (PostID))

            cadena = cursor.fetchone()[0]

            cursor.execute("UPDATE zf_posts SET content = '%s'" %
(unicode(cadena,'latin-1')))
    cursor.close()
    conn.commit()
    conn.close()




Más información sobre la lista de distribución Python-es