Guest User

Untitled

a guest
Sep 6th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. zipped = [('akamaitechnologies.com', 8221, 0), ('akamaitechnologies.com', 2053, 0), ('googleusercontent.com', 1119, 0), ('1e100.net', 3999, 0), ('1e100.net', 2819, 0)]`
  2.  
  3. CREATE TABLE `dns` (
  4. `id` int(10) NOT NULL AUTO_INCREMENT,
  5. `dnsname` text,
  6. `inbytes` int(11) DEFAULT NULL,
  7. `outbytes` int(11) DEFAULT NULL,
  8. PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  10.  
  11. #one function for connect & execute query
  12. def mysql_conn2(fhost, finb, foutb):
  13. cnx = mysql.connector.connect(user=mysql_user, password=mysql_password, database=mysql_database, host=mysql_host)
  14. cursor = cnx.cursor()
  15. cursor.execute("INSERT into dns (`dnsname`,`inbytes`,`outbytes`) VALUES(%s,%s,%s);", (fhost, finb, foutb))
  16. cnx.close()
  17.  
  18. #my script, that i have ro run
  19. for item in zipped:
  20. host = str(item[0])
  21. inb = str(item[1])
  22. outb = str(item[2])
  23. print(host,inb, outb)
  24. mysql_conn2(host,inb,outb)
Add Comment
Please, Sign In to add comment