python 爬虫系列01-连接mysql

爬虫学习中.........................................

import pymysql
conn = pymysql.connect(host='172.16.1.52',user='root',password='123456',database='mysql',port=3306)
curor = conn.cursor()
sql = """
select user,host from user
"""
curor.execute(sql)
results = curor.fetchmany(2)
for result in results:
    print(result)
conn.close()

 

posted on 2018-11-06 16:34  kingle-l  阅读(573)  评论(0编辑  收藏  举报

levels of contents