mysql sql语句修改某一字段下所有记录的大小写。

# -*- coding: utf-8 -*-

import pymysql

db = pymysql.connect(
    host='127.0.0.1',
    db='weixin',
    user="root",
    password="1233211234567Aa*",
    charset='utf8',

)
cursor = db.cursor(pymysql.cursors.DictCursor)#字典的形式获取数据  不写默认是元组
try:
    cursor.execute("update plugin set name=lower(name)")#把表plugin下name字段下所有的值改为小写。UCASE()为大写
except Exception, e:
    print e

try:
    cursor.execute("select name from plugin")#字典的形式获取数据 不写默认是元组
    data=cursor.fetchall()
    for i in data:
        print i['name']
except Exception, e:
    print e


db.commit()
cursor.close()
db.close()
原文地址:https://www.cnblogs.com/qxh-beijing2016/p/13154844.html