mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 10:31:02 +02:00
Add a truncate option for sections.
This commit is contained in:
parent
723baaefa0
commit
220f055d12
@ -441,6 +441,11 @@ table::
|
||||
|
||||
The table name of the database where to load data.
|
||||
|
||||
truncate::
|
||||
|
||||
+pgloader+ issues a +TRUNCATE <table>+ SQL command before
|
||||
importing data.
|
||||
|
||||
format::
|
||||
+
|
||||
The format data are to be found, either +text+, +csv+ or +fixed+.
|
||||
|
||||
@ -284,6 +284,13 @@ class PGLoader(threading.Thread):
|
||||
if not DRY_RUN:
|
||||
self.log.debug("%s: '%s'", opt, self.db.pg_options[opt])
|
||||
|
||||
# optionnal local option truncate
|
||||
self.truncate = TRUNCATE
|
||||
if config.has_option(name, 'truncate'):
|
||||
self.truncate = parse_config_string(
|
||||
config.get(name, 'truncate'))
|
||||
self.log.debug("truncate: '%s'", self.truncate)
|
||||
|
||||
# optionnal local pg_options
|
||||
# precedence is given to command line parsing, which is in PG_OPTIONS
|
||||
from tools import parse_pg_options
|
||||
@ -1184,7 +1191,7 @@ class PGLoader(threading.Thread):
|
||||
return
|
||||
|
||||
if not DRY_RUN:
|
||||
if TRUNCATE:
|
||||
if self.truncate:
|
||||
self.db.truncate(self.table)
|
||||
|
||||
if TRIGGERS:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user