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().
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to