How to insert multiple rows in SQLite Dbase

afandi afandimscit at gmail.com
Mon Apr 21 07:10:39 EDT 2008


On Apr 1, 12:22 am, afandi <afandims... at gmail.com> wrote:
> On Mar 30, 4:46 am, Gerhard Häring <g... at ghaering.de> 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
> >multipleexecute() 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?

I have the solution.Thanks
split it using REgex to [] [] []
parse to Database



More information about the Python-list mailing list