Created
December 8, 2014 10:13
-
-
Save libbkmz/5d8dde389bb75439af40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- codin: utf-8 -*- | |
import fileinput | |
import re | |
tb_list = [] | |
current_tb = "" | |
previous_tb = "" | |
new_line = "" | |
keys = {} | |
counter = 0 | |
counter_tb = 0 | |
tbs = 0 | |
for line in fileinput.input(): | |
counter += 1 | |
counter_tb += 1 | |
if line.startswith("DROP TABLE IF EXISTS"): | |
new_line = "UNLOCK TABLES;\n" | |
line = new_line + line | |
if line.startswith("CREATE TABLE"): | |
if current_tb: | |
# new_line = "UNLOCK TABLES;\n" | |
new_line = "ALTER TABLE %s ENABLE KEYS;\n" % (current_tb) | |
line = new_line + line; | |
current_tb = line.split("`")[1] | |
if line.endswith("CHARSET=utf8;\r\n"): | |
new_line = "ALTER TABLE %s DISABLE KEYS;\n" % (current_tb) | |
new_line += "LOCK TABLES %s WRITE;\n" % (current_tb) | |
line = line + new_line | |
# if line.startswith("INSERT"): | |
# line = line.replace("INSERT", "INSERT DELAYED") | |
if line.count("InnoDB") > 0: | |
line = line.replace("ENGINE=InnoDB", "ENGINE=MyISAM") | |
print line, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment