Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import getpass
- from MySQLdb import connect
- password = getpass.getpass()
- conn = connect(user="root", passwd=password)
- cur = conn.cursor()
- cur.execute("SELECT table_schema, table_name, table_collation FROM information_schema.tables WHERE table_collation = 'utf8_unicode_ci' and table_schema='onsetsource';")
- objs = cur.fetchall()
- db_to_update = objs[0][0]
- print "Updating %s db" % db_to_update
- print "-" * (12 + len(db_to_update))
- cur.execute("use %s" % db_to_update)
- for obj in objs:
- table_to_update = obj[1]
- print "Altering %s table" % table_to_update
- print "-" * (12 + len(table_to_update))
- query = "ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" % table_to_update
- cur.execute(query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement