Created
September 23, 2013 15:55
-
-
Save marceloandrader/6672678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from MySQLdb import connect | |
conn = connect(user="root", passwd="", host="localhost") | |
cur = conn.cursor() | |
cur.execute("show databases;") | |
dbs_to_update = filter( | |
lambda db: db in ('ppmd_coordinated'), | |
[dbname[0] for dbname in cur.fetchall()]) | |
for db_to_update in dbs_to_update: | |
print "Updating %s db" % db_to_update | |
print "-" * (12 + len(db_to_update)) | |
cur.execute("use %s" % db_to_update) | |
cur.execute("show tables;") | |
tables_to_update = [t[0] for t in cur.fetchall()] | |
for table_to_update in tables_to_update: | |
query = "ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" % table_to_update | |
cur.execute(query) | |
print table_to_update, "updated" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment