Re: [pysqlite] database locked

"Eric S. Johansson" <[email protected]> Mon, 02 Feb 2009 00:58:47 -0500
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Dennis Lee Bieber wrote:
> 	Something like
> 
> 	subresult = self.cursor.fetchall()[start:end]
> 
> adjust for zero offset as appropriate... and totally drop count...
> 
> 	Or use
> 
> 	for c, i in enumerate(subresult):
> 		if start <= c <= end:
> 			# do your mystic dictionary work here
> 			# rather than for all records you are just going to skip
> 			yield ...

and is revealed a wonderful problem.  I'm currently sitting at something like
20,000 records, and you retrieve them using fetch all in these cases, well, I
run out of memory real fast.  So, I need to go back and generate a different
select statement, one with limit and offset.

This brings me to another question, when you have the select statements with the
appropriate substitution mechanism (i.e."?"), how do you handle the situation
where you have a variable number of substitutions per select statement and match
up the right select statements to the right fields?  There are three or four
ways I can see of dealing with this.  The first is to have multiple select
statements.  Each doing the same basic operation with some variation.  Have some
sort of parameterized argument mechanism.  Last, generate a list at the same
time as you generate the SQL statement so that the two matchup.

I'm probably going to go with the latter just because it's convenient in my
code.  It will be interesting to see how it works out.