I am trying to break a huge SQL file into little sql file and I am using python to achieve this, but the code that I'm using doesn't match and from what I've seen on google it should.
Here is the code:
import sys, re
p = [0]
f = open('/root/testsql/data.sql', 'r')
tables =["tabel1", "table2"]
contor = 0;
con = 0;
for line in f:
for table in tables:
stri = "root/testsql/" + str(con)
con = con + 1
stri2 = ".*" + table + ".*"
if re.match(stri2,line):
print table
f2 = open(stri,"w")
f2.write(line)
f2.close()
If anybody has an idea why re.match doesn't work, it would be much appreciated.
The sql file is very long (73595 lines)and contains lines like:
insert into table ...
insert into table
re.matchdid lead to matchs. Are you sure the text you show is what you're getting from the file?