Started to work with SQLite3 in Python3

Cecil Westerhof Cecil at decebal.nl
Sun Sep 20 20:40:13 CEST 2015


On Sunday 20 Sep 2015 18:44 CEST, Chris Angelico wrote:

> On Mon, Sep 21, 2015 at 1:49 AM, Cecil Westerhof <Cecil at decebal.nl> wrote:
>> - I understood that with for fuel in fuel_cursor: a fetchall will
>> be executed. At the moment I do not see this as a problem, but if
>> the table would become very big it could. Would it be better to
>> rewrite it with a fetchone? But that is then needed inside and
>> before the loop. What would be a little ugly.
>
> It iterates over the query, but it doesn't fetchall() into a list.
> So it's as good as using fetchone().

You are right. I found this:
    http://pythoncentral.io/introduction-to-sqlite-in-python/
where at:
    Retrieving Data (SELECT) with SQLite
it says:
    The cursor object works as an iterator, invoking fetchall()
    automatically:
but all other places (I did a more extended search now) say the same
as you. So this problem is solved. :-)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the Python-list mailing list