On Mar 30, 4:46 am, Gerhard Häring <[EMAIL PROTECTED]> wrote: > Gabriel Genellina wrote: > > [...] > > and execute: > > cur.executemany("insert into log (IP, EntryDate, Requestt, ErrorCode) > > values (:ip, :date, :request, :errorcode)", values) > > It's probably worth mentioning that pysqlite's executemany() accepts > anything iterable for its parameter. So you don't need to build a list > beforehand to enjoy the performance boost of executemany(). > > 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()) > > -- Gerhard > > PS: pysqlite internally has a statement cache since verson 2.2, so > multiple execute() calls are almost as fast as executemany().
Thanks regards to your suggestion, but I don't understand why we have to put the IF statement? -- http://mail.python.org/mailman/listinfo/python-list