These days I was tortured by a strange problem about fetching data from remote mysql server in a container. Looking forward somebody here could help me out of the tough problem.
Here is the problem:
When I try to run the following code in a docker container, it would get blocked at line 5, while outside docker container everything is ok. The only difference between line 4 and line 5 is the returned columns in select statement.
Here are the codes:
1 import MySQLdb as mysql_driver
2 conn_ = mysql_driver.connect(host=‘100.72.9.24’, port=3306, user=“datagrand”, passwd=‘Leader112018’, db=‘siterec_datacenter’,connect_timeout=20)
3 cursor_ = conn_.cursor()
4 cursor_.execute(“select appid, itemid, cateid, score, title, price, item_modify_time from item_info where appid=926097 and item_infoid >0 and is_online=1 order by item_infoid limit 200”)
5 cursor_.execute(“select * from item_info where appid=926097 and item_infoid >0 and is_online=1 order by item_infoid limit 200”)