Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zipped = [('akamaitechnologies.com', 8221, 0), ('akamaitechnologies.com', 2053, 0), ('googleusercontent.com', 1119, 0), ('1e100.net', 3999, 0), ('1e100.net', 2819, 0)]`
- CREATE TABLE `dns` (
- `id` int(10) NOT NULL AUTO_INCREMENT,
- `dnsname` text,
- `inbytes` int(11) DEFAULT NULL,
- `outbytes` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- #one function for connect & execute query
- def mysql_conn2(fhost, finb, foutb):
- cnx = mysql.connector.connect(user=mysql_user, password=mysql_password, database=mysql_database, host=mysql_host)
- cursor = cnx.cursor()
- cursor.execute("INSERT into dns (`dnsname`,`inbytes`,`outbytes`) VALUES(%s,%s,%s);", (fhost, finb, foutb))
- cnx.close()
- #my script, that i have ro run
- for item in zipped:
- host = str(item[0])
- inb = str(item[1])
- outb = str(item[2])
- print(host,inb, outb)
- mysql_conn2(host,inb,outb)
Add Comment
Please, Sign In to add comment