Skip to content
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
14 changes: 12 additions & 2 deletions db_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def parse(input_filename, output_filename):
elif line.startswith("INSERT INTO"):
output.write(line.encode("utf8").replace("'0000-00-00 00:00:00'", "NULL") + "\n")
num_inserts += 1
elif line.startswith("CREATE DATABASE"):
db_name = line.split('"')[1]
output.write("COMMIT;\n")
output.write(u"CREATE DATABASE \"%s\";\n" % db_name)
elif line.startswith("USE "):
db_name = line.split('"')[1]
output.write(u"\connect \"%s\"\n" % db_name)
output.write("START TRANSACTION;\n")
# ???
else:
print "\n ! Unknown line in main body: %s" % line
Expand Down Expand Up @@ -134,9 +142,11 @@ def parse(input_filename, output_filename):
set_sequence = True
elif type == "datetime":
type = "timestamp with time zone"
elif type == "double":
elif type.startswith("double"):
type = "double precision"
elif type == "blob":
elif type.startswith("float"):
type = "real"
elif "blob" in type:
type = "bytea"
elif type.startswith("enum(") or type.startswith("set("):

Expand Down