[Numpy-discussion] loading database data into numpy arrays

John Salvatier jsalvati at u.washington.edu
Thu Aug 19 13:23:22 EDT 2010


 That worked! Thanks!

On Thu, Aug 19, 2010 at 10:18 AM, Keith Goodman <kwgoodman at gmail.com> wrote:

> On Thu, Aug 19, 2010 at 10:00 AM, John Salvatier
> <jsalvati at u.washington.edu> wrote:
> > Hello,
> >
> > I am trying to load some time series data into numpy arrays from a MySQL
> > database using pyodbc, but I am not sure what the standard way to do this
> > is. I found the following:
> > http://www.aidanfindlater.com/python-db-api-to-numpy but when I tried
> after
> > doing a select (I made sure the cursor had rows).
> >
> > np.fromiter(cursor, dtype=[('a',float), ('b', float)])
> >
> > I got
> >
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "C:\Users\jsalvatier\workspace\rpxdata\src\rpxdata\mysql.py", line
> > 45, in run_statistics_15
> >     return np.fromiter(cursor, dtype=[('a',float), ('b', float)])
> > TypeError: expected a readable buffer object
> >
> > Does anyone have advice on this?
>
> How about np.asarray(cursor.fetchall())?
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100819/98011b25/attachment.html>


More information about the NumPy-Discussion mailing list