Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

Connector escape strings (no replies)

$
0
0
Good day and have a nice day!
i use mysqlConnector with python 3.6.5

In python i have list:

zipped = [('akamaitechnologies.com', 8221, 0), ('akamaitechnologies.com', 2053, 0), ('googleusercontent.com', 1119, 0), ('1e100.net', 3999, 0), ('1e100.net', 2819, 0)]`

Also i have datasase with simple table:

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

And my code:

#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)

But then i check up my table - but there arent any rows! Empty... If i manually add row - that is OK status.
When i debug my script - i see it: IMGUR
I see en error - escaped stings in cursor.statement property, why so?

How can i unescape these rows / may be i do something wrong?
thanks for help!

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>