File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ def safechardecode(value):
177177 else :
178178 break
179179
180- elif isinstance (value , list ):
180+ elif isinstance (value , ( list , tuple ) ):
181181 for i in xrange (len (value )):
182182 retVal [i ] = safechardecode (value [i ])
183183
Original file line number Diff line number Diff line change @@ -358,6 +358,9 @@ def dbTableValues(self, tableValues):
358358 if not conf .multipleTargets and not conf .replicate :
359359 dataToDumpFile (dumpFP , "\n " )
360360
361+ if conf .replicate :
362+ rtable .beginTransaction ()
363+
361364 for i in range (count ):
362365 field = 1
363366 values = []
@@ -398,11 +401,12 @@ def dbTableValues(self, tableValues):
398401 self .__write ("%s\n " % separator )
399402
400403 if conf .replicate :
404+ rtable .endTransaction ()
401405 logger .info ("Table '%s.%s' dumped to sqlite3 file '%s'" % (db , table , replication .dbpath ))
406+
402407 elif not conf .multipleTargets :
403408 dataToDumpFile (dumpFP , "\n " )
404409 dumpFP .close ()
405-
406410 logger .info ("Table '%s.%s' dumped to CSV file '%s'" % (db , table , dumpFileName ))
407411
408412 def dbColumns (self , dbColumns , colConsider , dbs ):
Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ def insert(self, values):
7171 errMsg = "wrong number of columns used in replicating insert"
7272 raise sqlmapValueException , errMsg
7373
74+ def beginTransaction (self ):
75+ """
76+ Great speed improvement can be gained by using explicit transactions around multiple inserts.
77+ Reference: http://stackoverflow.com/questions/4719836/python-and-sqlite3-adding-thousands-of-rows
78+ """
79+ self .parent .cursor .execute ('BEGIN TRANSACTION' )
80+
81+ def endTransaction (self ):
82+ self .parent .cursor .execute ('END TRANSACTION' )
83+
7484 def select (self , condition = None ):
7585 """
7686 This function is used for selecting row(s) from current table.
You can’t perform that action at this time.
0 commit comments