def executeBatch(cursor, sql,<EOL>regex=r"<STR_LIT>",<EOL>comment_regex=r"<STR_LIT>"):
<EOL>sql = "<STR_LIT:\n>".join([x.strip().replace("<STR_LIT:%>", "<STR_LIT>") for x in re.split(comment_regex, sql) if x.strip()])<EOL>in_proc = False<EOL>statements = []<EOL>for st in re.split(regex, sql)[<NUM_LIT:1>:][::<NUM_LIT:2>]:<EOL><INDENT>if st.strip().lower().startswith("<STR_LIT>"):<EOL><INDENT>in_proc = not in_proc<EOL>if statements and not in_proc:<EOL><INDENT>procedure = "<STR_LIT:;>".join(statements)<EOL>statements = []<EOL>cursor.execute(procedure)<EOL><DEDENT>continue<EOL><DEDENT>if in_proc:<EOL><INDENT>statements.append(st)<EOL><DEDENT>else:<EOL><INDENT>cursor.execute(st)<EOL><DEDENT><DEDENT>
Takes a SQL file and executes it as many separate statements.

TODO: replace regexes with something easier to grok and extend.