我正在尝试使用pymysql进行SELECT,并且我不断获得error: [Errno 32] Broken pipe
。我错过了什么?在我的本地机器上一切正常,将它带到生产休息时间。我正在运行EC2 Micro实例。
`import pymysql
def connection():
db = pymysql.connect(host='localhost', port=3306, user='**',
passwd='**',db='blog',charset='utf8')
cur = db.cursor()
cur.execute('SET NAMES utf8;')
cur.execute('SET CHARACTER SET utf8;')
cur.execute('SET character_set_connection=utf8;')
return (cur,db) #Returns both curson and connection`
获取数据的代码
`cur.execute("SELECT * FROM nse WHERE DATE(created_at) =
(SELECT DATE(created_at) FROM nse ORDER BY id DESC LIMIT 1)",)
for r in cur.fetchall():
STOCKS[r[2]] =dict(date=r[1],symbol=r[2],open=r[3],high=r[4],low=r[5],close=r[6],change=r[7],deals=r[8],units=r[9],value=r[10])
return STOCKS`
你指出的是C
,并不能满足我的需要。
谢谢。