mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-05-10 18:53:44 +03:00
Adding support for appending to the existing table dump if --start/--stop is used
This commit is contained in:
parent
e3a02f56e6
commit
63d7707346
|
@ -366,6 +366,7 @@ class Dump(object):
|
||||||
replication = None
|
replication = None
|
||||||
rtable = None
|
rtable = None
|
||||||
dumpFP = None
|
dumpFP = None
|
||||||
|
appendToFile = False
|
||||||
|
|
||||||
if tableValues is None:
|
if tableValues is None:
|
||||||
return
|
return
|
||||||
|
@ -388,7 +389,8 @@ class Dump(object):
|
||||||
os.makedirs(dumpDbPath, 0755)
|
os.makedirs(dumpDbPath, 0755)
|
||||||
|
|
||||||
dumpFileName = "%s%s%s.%s" % (dumpDbPath, os.sep, unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())
|
dumpFileName = "%s%s%s.%s" % (dumpDbPath, os.sep, unsafeSQLIdentificatorNaming(table), conf.dumpFormat.lower())
|
||||||
dumpFP = openFile(dumpFileName, "wb")
|
appendToFile = os.path.isfile(dumpFileName) and any((conf.limitStart, conf.limitStop))
|
||||||
|
dumpFP = openFile(dumpFileName, "wb" if not appendToFile else "ab")
|
||||||
|
|
||||||
count = int(tableValues["__infos__"]["count"])
|
count = int(tableValues["__infos__"]["count"])
|
||||||
separator = str()
|
separator = str()
|
||||||
|
@ -466,6 +468,7 @@ class Dump(object):
|
||||||
|
|
||||||
self._write("| %s%s" % (column, blank), newline=False)
|
self._write("| %s%s" % (column, blank), newline=False)
|
||||||
|
|
||||||
|
if not appendToFile:
|
||||||
if conf.dumpFormat == DUMP_FORMAT.CSV:
|
if conf.dumpFormat == DUMP_FORMAT.CSV:
|
||||||
if field == fields:
|
if field == fields:
|
||||||
dataToDumpFile(dumpFP, "%s" % safeCSValue(column))
|
dataToDumpFile(dumpFP, "%s" % safeCSValue(column))
|
||||||
|
@ -481,7 +484,7 @@ class Dump(object):
|
||||||
self._write("|\n%s" % separator)
|
self._write("|\n%s" % separator)
|
||||||
|
|
||||||
if conf.dumpFormat == DUMP_FORMAT.CSV:
|
if conf.dumpFormat == DUMP_FORMAT.CSV:
|
||||||
dataToDumpFile(dumpFP, "\n")
|
dataToDumpFile(dumpFP, "\n" if not appendToFile else "")
|
||||||
|
|
||||||
elif conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
elif conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||||
rtable.beginTransaction()
|
rtable.beginTransaction()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user