Recently, I was looking for “best practices” for getting data from MySQL to a numpy array. Thanks to Tim Hochberg on the numpy mailing list, we get the following as the apparently fastest way to bridge the DB-numpy gap:
# CREATE TABLE demo (x REAL, y REAL)
c = conn.cursor()
c.execute('SELECT * FROM demo')
y = numpy.fromiter(c, dtype=[('a',float), ('b', float)])
At least, it was the fastest back in 2006.
Author
jsalvatierDate
August 19, 2010Time
12:03 pmAuthor
jsalvatierDate
August 19, 2010Time
4:59 pmAuthor
jsalvatierDate
August 19, 2010Time
5:10 pm