from MySQLdb import *

c = connect(host = "localhost", user="계정아이디", passwd="비밀번호", db="데이터베이스이름")
cursor = c.cursor()

cursor.execute('select post_id from phpbb_posts_text where post_text like "%moraebat%";')

post_id_list = [cols[0] for cols in cursor.fetchall()]

for post_id in post_id_list:
cursor.execute("select topic_id, forum_id from phpbb_posts where post_id = %d;" % (post_id))
topic_id, forum_id = cursor.fetchall()[0]

print post_id, topic_id, forum_id
cursor.execute("delete from phpbb_posts_text where post_id = %d limit 1;" % (post_id))
cursor.execute("delete from phpbb_posts where post_id = %d limit 1;" % (post_id))
cursor.execute("delete from phpbb_topics where topic_id = %d limit 1;" % (topic_id))

이올린에 북마크하기(0) 이올린에 추천하기(0)
2010/01/30 20:25 2010/01/30 20:25