1
Этот код работает с python3, если я использую обычный курсор (т. Е. cur = con.cursor()
).python3 работает со значениями fetchall и DictCursor
Как я могу заставить этот код работать, если я хочу использовать DictCursor
? (Т.е. cur = con.cursor(mdb.cursors.DictCursor)
)
include numpy as np
import pymysql as mdb
--- cut ---
cur.execute("select id from history where category=%s;",("DATA"))
rows = cur.fetchall()
num_rows = int(cur.rowcount)
# recast this nested tuple to a python list and flatten it so it's a proper iterable:
x = map(list, list(rows)) # change the type
x = sum(x, []) # flatten
D = np.fromiter(iter=x, dtype=float, count=-1)
---
Спасибо, что решает мою проблему :) – Intra