[Tutor] working with data in a database...

Lloyd Kvam pythontutor@venix.com
Thu, 18 Apr 2002 08:29:25 -0400


(Ideas here were lifted from Hammon & Robinson as well as Norvig)
After executing a cursor:
	self._datanames = [info[0] for info in cursor.description]
	self._datarows = list(cursor.fetchall())
	self._datacols = zip(*self._datarows)
Assuming that your thousand row fits easily into memory, this gives you
access to your data by row and by column.  It is easy to find the
sum, max, min or whatever for any column.  Any ancillary routines for
your needs should be easy to write.

Israel Evans wrote:

>  
> 
> I'm currently trying to work with a small to middling amount of data ( 
> about a thousand rows or so ),  and I'm wondering about the best approach.
> 
> It seems that to analyze, compare, and otherwise play around with the 
> data, it would be easier just to extract it all out of the database and 
> manipulate a couple of instances of various classes.  Playing with 
> strings, tuples, lists and dicts makes a lot of sense to me right now 
> and my SQL skills leave something to be desired.  Though I realize that 
> I could take a definite performance hit were my data set to grow by any 
> substantial amount and that by going around the database, I'm neglecting 
> a very valuable tool.  I'm just new enough at this that I don't really 
> see how best to proceed.
> 
>  
> 
> Are there any resources you database masters out there cherish and 
> wouldn't leave the house without?  How you chosen to deal with data 
> housed in databases?  What are your favorite methods?  Any hints, 
> suggestions or random musings are welcome...
> 
>  
> 
> Thanks,
> 
>  
> 
>  
> 
>  
> 
> ~Israel~
> 
>  
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582