Created
August 25, 2016 02:40
-
-
Save jackeyGao/db862c6066d86f602826658b88895005 to your computer and use it in GitHub Desktop.
DELETE TO INSERT
This file contains hidden or 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
| with open('del.sql', 'r') as f: | |
| insert = "" | |
| for i in f.readlines(): | |
| if i.startswith('### DELETE FROM'): | |
| insert = insert.strip(',') + ';' | |
| if insert != ';': | |
| print insert | |
| insert = "INSERT INTO" | |
| insert += i.split('FROM')[1].strip('\n') | |
| if i.startswith('### WHERE'): | |
| insert += " SELECT " | |
| if i.startswith('### @'): | |
| insert += i.split('=')[1].strip('\n') + ',' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment