0

我正在尝试使用 pymysql 的 SELECT 并且我不断得到error: [Errno 32] Broken pipe. 我错过了什么?在我的本地机器上一切正常,将其用于生产中断。我正在运行一个 EC2 微型实例。

    `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并不完全符合我的需要。谢谢你。

4

0 回答 0