Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import re
- import MySQLdb
- pattern = re.compile('@(.*)@.*$')
- conn = MySQLdb.connect(
- host='localhost', user='root',
- passwd='password', db='j314', charset='utf8')
- cursor = conn.cursor()
- cursor.execute(
- """select `id`, `created_by_alias` from w0z9v_content where `catid` = 13 AND `created_by_alias` regexp "^@.*@.*$" limit 400""")
- aliases = cursor.fetchall()
- for alias in aliases:
- # print alias
- newalias = pattern.match(alias[1])
- # print newalias
- if newalias.group(1) is not None:
- cursor.execute("""
- update w0z9v_content set `created_by_alias`=%s where `id` = '%s'""", (newalias.group(1), alias[0]))
- conn.close
Advertisement
Add Comment
Please, Sign In to add comment