Created
July 19, 2013 17:14
-
-
Save kanazux/6040808 to your computer and use it in GitHub Desktop.
Read data from pipe and send to mysql db
This file contains 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
#!/usr/local/bin/python -u | |
import sys | |
import subprocess | |
conn = 'mysql -p123 -b webfilter' | |
ins_mysql = '-e "insert into ntable (url_str, elapsed_ms, size_bytes, ip, username) values (\'%s\', %s, %s, \'%s\', \'%s\')' | |
while 1: | |
fd=sys.stdin.readline() | |
itemAcc=fd.split() | |
subprocess.call(['%s %s' % (conn, ins_mysql, itemAcc[6], itemAcc[1], itemAcc[4], itemAcc[2], itemAcc[7])], shell=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment