# Author:JiangYiyang
import pymysql
conn = pymysql.connect(
host='localhost',
port=3306,
user='confluenct',
password='jyy',
db='confluence',
use_unicode=True,
cursorclass=pymysql.cursors.DictCursor)
cursor = conn.cursor()
conn.autocommit(True)
cursor.execute('show tables;')
data = cursor.fetchall()
for item in data:
table_name=item['Tables_in_confluence']
cursor.execute(
'alter table %s convert to character set utf8mb4 collate utf8mb4_bin;'%(table_name)
)
cursor.execute('show create table users;')
data2 = cursor.fetchall()
print(data2)
cursor.close()
conn.close()
Python自动化之批量修改数据库字符集
最新推荐文章于 2022-12-17 12:54:52 发布