[SciPy-user] storing numpy arrays

Brian Granger ellisonbg.net at gmail.com
Fri Mar 13 13:36:40 EDT 2009


Another option that could be better is to simply store the name of a
file containing the array in the db and then just write the array to
the file (use the array hash as a filename) using the NPY format.
Depending on the size and number of arrays, there could be a
performance benefit to this approach compared to storing the full
array in the db.

Brian

On Thu, Mar 12, 2009 at 2:35 PM, Michael Hearne <mhearne at usgs.gov> wrote:
> I have a MySQL database, in which I would like to store a numpy array as
> a BLOB.  I'm trying to find out the easiest/most efficient way to
> store/extract this data.
>
> I looked at scipy.io.write_array, which looked somewhat promising, until
> I saw the notice that this method is deprecated in favor of numpy.savetxt.
>
> I could potentially use scipy.io.savemat/loadmat, but that would require
> writing to a binary (.mat file), then reading it back in again just to
> stuff it into the database.
>
> I could also use pickle, but I found a bug report somewhere that pickle
> may do strange things to the array in the process or reading or writing.
>
> Does anyone have any suggestions?
>
> Thanks,
>
> Mike
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list