I have a huge (1GB+) database dump that I want to load into new databases on other servers. I tried parsing it line by line and executing each into mysql, but it unfortunately doesn't split lines evenly into commands and just fails on the incomplete ones.
filename='/var/test.sql'
fp = open(filename)
while True:
a = fp.readline()
if not a:
break
cursor.execute(a) #fails most of the time
It is also way too large to load the entire thing into memory call that. Furthermore, the python MySQLdb module does not support the source command.
EDITED
File includes a bunch of insert and create statements. Where its failing is on the inserts of large tables that contain raw text. There are all sorts of semi-colons and newlines in the raw text so hard to split commands based on that.