How to insert multiple rows in SQLite Dbase

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Mar 31 13:35:26 EDT 2008


En Mon, 31 Mar 2008 11:22:40 -0300, afandi <afandimscit at gmail.com>  
escribió:
> On Mar 30, 4:46 am, Gerhard Häring <g... at ghaering.de> wrote:
>>
>> The deluxe version with generators could look like this:
>>
>> def parse_logfile():
>>     logf = open(...)
>>     for line in logf:
>>         if ...:
>>           row = (value1, value2, value3)
>>           yield row
>>     logf.close()
>>
>> ...
>>
>> cur.executemany("insert into ... values (c1, c2, c3)", parse_logfile())
>
> Thanks regards to your suggestion, but I don't understand why we have
> to put the IF statement?

Which if statement? The if inside parse_logfile quoted above is just an  
example, it's not essential.

-- 
Gabriel Genellina




More information about the Python-list mailing list