MySQL怎么批量转换表名为小写
发布时间:2022-01-20 14:35:58 所属栏目:MySql教程 来源:互联网
导读:本篇内容介绍了MySQL怎么批量转换表名为小写的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! #!/usr/bin/env python # -*-encoding:utf8-*- # impor
本篇内容介绍了“MySQL怎么批量转换表名为小写”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! #!/usr/bin/env python # -*-encoding:utf8-*- # import MySQLdb import time step = 0 db = MySQLdb.connect(host = '192.168.20.42',port = 61306,user = 'test',passwd = 'test' , db = 'information_schema') conn = db.cursor() sql = '''select TABLE_SCHEMA, table_name from information_schema.tables where table_schema not in ('information_schema', 'performance_schema', 'mysql') ''' # print sql conn.execute(sql) if conn.rowcount > 0: for item in conn.fetchall(): sql = '''rename table %s.%s to %s.%s''' % (item[0], item[1], item[0], item[1].lower()) if item[1].isupper(): print sql conn.execute(sql) time.sleep(0.5) conn.close() db.close() “MySQL怎么批量转换表名为小写”的内容就介绍到这里了,感谢大家的阅读。 (编辑:包头站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐