Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复Python3使用时的错误 #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions db_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def parse(input_filename, output_filename):
secs_left % 60,
))
logging.flush()
line = line.decode("utf8").strip().replace(r"\\", "WUBWUBREALSLASHWUB").replace(r"\'", "''").replace("WUBWUBREALSLASHWUB", r"\\")
line = line.encode('utf-8').decode('utf8').strip().replace(r"\\", "WUBWUBREALSLASHWUB").replace(r"\'", "''").replace("WUBWUBREALSLASHWUB", r"\\")
# Ignore comment lines
if line.startswith("--") or line.startswith("/*") or line.startswith("LOCK TABLES") or line.startswith("DROP TABLE") or line.startswith("UNLOCK TABLES") or not line:
continue
Expand All @@ -83,11 +83,11 @@ def parse(input_filename, output_filename):
creation_lines = []
# Inserting data into a table?
elif line.startswith("INSERT INTO"):
output.write(line.encode("utf8").replace("'0000-00-00 00:00:00'", "NULL") + "\n")
output.write(line.encode("utf8").decode('utf8').replace("'0000-00-00 00:00:00'", "NULL") + "\n")
num_inserts += 1
# ???
else:
print "\n ! Unknown line in main body: %s" % line
print("\n ! Unknown line in main body: %s" % line)

# Inside-create-statement handling
else:
Expand Down Expand Up @@ -187,7 +187,7 @@ def parse(input_filename, output_filename):
current_table = None
# ???
else:
print "\n ! Unknown line inside table creation: %s" % line
print("\n ! Unknown line inside table creation: %s" % line)


# Finish file
Expand Down Expand Up @@ -218,7 +218,7 @@ def parse(input_filename, output_filename):
# Finish file
output.write("\n")
output.write("COMMIT;\n")
print ""
print("")


if __name__ == "__main__":
Expand Down