import pymysql
db = pymysql.connect("数据库ip","账号","密码","数据库")
cr = db.cursor()
sql_select ="select * from test"
cr.execute(sql_select)
select = cr.fetchall()#fetchall:返回全部值,fetchone():返回一条数据
来源:oschina
链接:https://my.oschina.net/u/4515679/blog/4331883