def remove_user(uid): user = User.get(uid) if not user: print '---no user:%s' % uid print "---- delete from user, uid=", uid db_conn.execute("delete from user where id=%s", uid) db_conn.commit() User._clear_cache(uid) cursor = db_conn.execute("select id from status where user_id=%s", uid) if cursor: rows = cursor.fetchall() for row in rows: sid = row[0] print "---- delete mongo text, sid=", sid RawStatus.remove(sid) print "---- delete from status, uid=", uid db_conn.execute("delete from status where user_id=%s", uid) db_conn.commit() Status._clear_cache(uid, None) print "---- delete from passwd, uid=", uid db_conn.execute("delete from passwd where user_id=%s", uid) print "---- delete from sync_task, uid=", uid db_conn.execute("delete from sync_task where user_id=%s", uid) print "---- delete from user_alias, uid=", uid db_conn.execute("delete from user_alias where user_id=%s", uid) db_conn.commit()
def remove_user(uid, clear_status=True): user = User.get(uid) if not user: print "---no user:%s" % uid suicide_log.info("---- delete from user, uid=%s" % uid) db_conn.execute("delete from user where id=%s", uid) db_conn.commit() User._clear_cache(uid) if clear_status: cursor = db_conn.execute("select id from status where user_id=%s", uid) if cursor: rows = cursor.fetchall() for row in rows: sid = row[0] suicide_log.info("---- delete status text, sid=%s" % sid) RawStatus.remove(sid) suicide_log.info("---- delete from status, uid=" % uid) db_conn.execute("delete from status where user_id=%s", uid) db_conn.commit() Status._clear_cache(uid, None) suicide_log.info("---- delete from passwd, uid=%s" % uid) db_conn.execute("delete from passwd where user_id=%s", uid) suicide_log.info("---- delete from sync_task, uid=%s" % uid) db_conn.execute("delete from sync_task where user_id=%s", uid) suicide_log.info("---- delete from user_alias, uid=%s" % uid) db_conn.execute("delete from user_alias where user_id=%s", uid) db_conn.commit()
def remove_user(uid, clear_status=True): user = User.get(uid) if not user: print '---no user:%s' % uid suicide_log.info("---- delete from user, uid=%s" % uid) db_conn.execute("delete from user where id=%s", uid) db_conn.commit() User._clear_cache(uid) if clear_status: cursor = db_conn.execute("select id from status where user_id=%s", uid) if cursor: rows = cursor.fetchall() for row in rows: sid = row[0] suicide_log.info("---- delete status text, sid=%s" % sid) RawStatus.remove(sid) suicide_log.info("---- delete from status, uid=" % uid) db_conn.execute("delete from status where user_id=%s", uid) db_conn.commit() Status._clear_cache(uid, None) suicide_log.info("---- delete from passwd, uid=%s" % uid) db_conn.execute("delete from passwd where user_id=%s", uid) suicide_log.info("---- delete from sync_task, uid=%s" % uid) db_conn.execute("delete from sync_task where user_id=%s", uid) suicide_log.info("---- delete from user_alias, uid=%s" % uid) db_conn.execute("delete from user_alias where user_id=%s", uid) db_conn.commit()
def remove_status(uid): cursor = db_conn.execute("select id from status where user_id=%s", uid) if cursor: rows = cursor.fetchall() for row in rows: sid = row[0] print "---- delete mongo text, sid=", sid RawStatus.remove(sid) print "---- delete from status, uid=", uid db_conn.execute("delete from status where user_id=%s", uid) db_conn.commit() Status._clear_cache(uid, None)
sys.path.append('../') import datetime import past from past.store import db_conn from past.utils.escape import json_decode from past.model.kv import RawStatus cursor = db_conn.execute("select id from status where category=200") rows = cursor.fetchall() cursor and cursor.close() ids = [x[0] for x in rows] for x in ids: try: r = RawStatus.get(x) raw = r.raw if r else "" if raw: print x data = json_decode(raw) t = data.get("created_at") created_at = datetime.datetime.strptime( t, "%a %b %d %H:%M:%S +0800 %Y") db_conn.execute("update status set create_time = %s where id=%s", (created_at, x)) db_conn.commit() except: import traceback print traceback.format_exc() sys.stdout.flush()
import sys sys.path.append('../') import datetime import past from past.store import db_conn from past.utils.escape import json_decode from past.model.kv import RawStatus cursor = db_conn.execute("select id from status where category=200") rows = cursor.fetchall() cursor and cursor.close() ids = [x[0] for x in rows] for x in ids: try: r = RawStatus.get(x) raw = r.raw if r else "" if raw: print x data = json_decode(raw) t = data.get("created_at") created_at = datetime.datetime.strptime(t, "%a %b %d %H:%M:%S +0800 %Y") db_conn.execute("update status set create_time = %s where id=%s", (created_at, x)) db_conn.commit() except: import traceback print traceback.format_exc() sys.stdout.flush()
#-*- coding:utf-8 -*- import sys sys.path.append('../') from datetime import timedelta from past.store import db_conn from past.model.kv import RawStatus with open("ids.txt") as f: for id_ in f: id_ = id_.rstrip("\n") print id_ cursor = db_conn.execute("delete from status where id=%s", id_) db_conn.commit() RawStatus.remove(id_) #cursor = db_conn.execute("select * from status where id=%s", id_) #print cursor.fetchone()