[Numpy-discussion] Recarray to and from sqlite

Vincent Nijs v-nijs at kellogg.northwestern.edu
Wed Jul 18 21:31:07 EDT 2007


I am trying to write a couple of simple functions to (1) save recarray's to
an sqlite database and (2) load a recarray from an sqllite database. I am
stuck on 2 points and hope there are some people on this list that use
sqlite for numpy stuff.

1. How to detect the variable names and types from the sqlite database?

I am using:

conn = 

but then how do you access the variable names and types and convert them to
numpy types?

2. In saving the recarray to sqlite I need to get data types from
data.dtype.descr and transform the names to types that sqlite knows:

string --> text
int --> integer
float --> real

I tried some things like:
for i in data[0]:
    if type(i) == str

This didn't work because the elements are numpy.strings and I couldn't get
the comparison to work. I'd rather use the dtype descriptions directly but
couldn't figure out how to do that either.

Any suggestions are very welcome.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070718/00e804cd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: load_sqlite.py
Type: application/octet-stream
Size: 1739 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070718/00e804cd/attachment.obj>

More information about the NumPy-Discussion mailing list