Created
June 23, 2015 09:02
-
-
Save sturgle/e6a0d2c870cfbe0423fe to your computer and use it in GitHub Desktop.
split large sql files into small ones
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
fin = open('Downloads/sub.sql', 'r') | |
cnt = 0 | |
fcnt = 0; | |
fout = open('output/out_' + `fcnt` + '.sql', 'w'); | |
with fin as ins: | |
for line in ins: | |
cnt = cnt + 1 | |
fout.write(line) | |
if line.startswith("commit") and cnt > 50000: | |
fout.close() | |
cnt = 0 | |
fcnt = fcnt + 1 | |
fout = open('output/out_' + `fcnt` + '.sql', 'w') | |
fin.close() | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment