- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11740
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
脚本没有发出来. 把核心思想记录在这里好了...
安装 http://dev.mysql.com/downloads/connector/python/- import mysql.connector as db
- cnx = db.connect(host = "127.0.0.1", user = "root", password = "", database = "test")
- if db.is_connected():
- print("OK")
- cursor = cnx.cursor()
- query_str = "select %s, %s from %s" % ("pid", "message", "forum_post")
- cursor.execute(query_str)
- res = cursor.fetchall() # a list of tuples
- for rec in res:
- update_key = rec[0]
- update_value = rec[1].replace("www.tcax.org", "www.tcax.org")
- update_str = "update forum_post set message = %s where pid = %s" %(update_value, update_key)
- cursor.execute(update_str)
- cursor.close()
- cnx.close()
复制代码 |
|