由于坚定的想坚持用python3,所以链接mysql的时候使用pymysql库,以下是遇到的坑:
1,连接的时候port是一个数字不是字符串
如下所示:
mport pymysql
conn = pymysql.connect(host='127.0.0.1',port = 3306,user='root',passwd='root',db = 'mysql')
如果写 port = "3306" 就连接不上了。
2,判断字段是不是空的时候用"is not null" 不能用" !='' "
select keyword, hert from data_table where keyword is not null and hert=1 limit 50;