[Numpy-discussion] Recarray to and from sqlite

Vincent Nijs v-nijs@kellogg.northwestern....
Wed Jul 18 20:31:07 CDT 2007


Hi,

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 = 
sqlite3.connect(fname,detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COL
NAMES)

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.

Thanks!!

Vincent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.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://projects.scipy.org/pipermail/numpy-discussion/attachments/20070718/00e804cd/attachment.obj 


More information about the Numpy-discussion mailing list