usr bin python coding utf-8 import re queries open queries txt pattern

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
queries = open('queries.txt', 'r')
pattern = re.compile('INSERT INTO `.*?` VALUES \((.*?)\);')
r = []
for q in queries.readlines():
q = q.strip()
values = pattern.findall(q)[0].split(', ')
for v in values:
v = v.replace('\'', '')
r.append(v)
print r[4], r[5], r[6]