mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 10:31:02 +02:00
template and -T documentation
This commit is contained in:
parent
1e7a16b869
commit
87b037fa8d
2
debian/files
vendored
2
debian/files
vendored
@ -1 +1 @@
|
||||
pgloader_2.2.4_all.deb misc extra
|
||||
pgloader_2.2.5-dev_all.deb misc extra
|
||||
|
||||
@ -9,7 +9,7 @@ pgloader - Import CSV data and Large Object to PostgreSQL
|
||||
pgloader [--version] [-c configuration file]
|
||||
[-p pedantic] [-d debug] [-v verbose] [-q quiet] [-s summary]
|
||||
[-n dryrun] [-Cn count] [-Fn from] [-In from id]
|
||||
[-E input files encoding]
|
||||
[-E input files encoding] [-R reformat:path]
|
||||
[Section1 Section2]
|
||||
|
||||
== DESCRIPTION ==
|
||||
@ -129,6 +129,12 @@ You can't use both -F and -I at the same time.
|
||||
|
||||
Input data files encoding. Defaults to 'latin9'.
|
||||
|
||||
-R, --reformat_path::
|
||||
|
||||
PATH where to find reformat python modules, defaults to
|
||||
+/usr/share/pgloader/reformat+. See +reformat_path+ option for
|
||||
syntax and default value.
|
||||
|
||||
Section::
|
||||
+
|
||||
is the name of a configured Section describing some data to load
|
||||
@ -254,6 +260,9 @@ configure with +reformat+ section specific option.
|
||||
Default value is +/usr/share/pgloader/reformat+, which is where the
|
||||
provided +debian+ package of +pgloader+ installs the +reformat+
|
||||
modules.
|
||||
+
|
||||
If the +-R+ or +--reformat_path+ command line option is used, it will
|
||||
have precedence over configuration file setting.
|
||||
|
||||
== COMMON FORMAT CONFIGURATION PARAMETERS ==
|
||||
|
||||
@ -265,6 +274,24 @@ First, we'll go through common parameters, applicable whichever format of data
|
||||
you're refering to. Then text-format only parameters will be presented,
|
||||
followed by csv-only parameters.
|
||||
|
||||
template::
|
||||
+
|
||||
When this option is set, current section is to be considered a
|
||||
template, that is only read from section(s) using it as so (see
|
||||
+use_template+ below).
|
||||
+
|
||||
The value given to the option is not taken into account by +pgloader+,
|
||||
only the fact that it exists has meaning. But +ConfigParser+ requires
|
||||
a value to be affected to consider the option set. Use +True+ as a
|
||||
value, for example.
|
||||
|
||||
use_template::
|
||||
+
|
||||
This option setting have to be the name of a template section, which
|
||||
can define the exact same options as a normal section. If the actual
|
||||
section and the +use_template+ template section both define the same
|
||||
option, the former is used: actual setting overrides template's one.
|
||||
|
||||
table::
|
||||
|
||||
The table name of the database where to load data.
|
||||
|
||||
@ -65,7 +65,7 @@ class PGLoader:
|
||||
self.template = config.get(name, 'use_template')
|
||||
|
||||
if not config.has_section(self.template):
|
||||
m = 'Error: %s refers to unknown template section %s' \
|
||||
m = '%s refers to unknown template section %s' \
|
||||
% (name, self.template)
|
||||
|
||||
raise PGLoader_Error, m
|
||||
@ -74,7 +74,16 @@ class PGLoader:
|
||||
if VERBOSE:
|
||||
print "Reading configuration from template section [%s]" \
|
||||
% self.template
|
||||
self.__read_conf__(self.template, config, db)
|
||||
|
||||
try:
|
||||
self.__read_conf__(self.template, config, db,
|
||||
want_template = True)
|
||||
except PGLoader_Error, e:
|
||||
print
|
||||
print e
|
||||
m = "%s.use_template does not refer to a template section"\
|
||||
% name
|
||||
raise PGLoader_Error, m
|
||||
|
||||
# reinit self.template now its relative config section is read
|
||||
self.template = None
|
||||
@ -96,9 +105,13 @@ class PGLoader:
|
||||
print '%s init done' % name
|
||||
print
|
||||
|
||||
def __read_conf__(self, name, config, db):
|
||||
def __read_conf__(self, name, config, db, want_template = False):
|
||||
""" init self from config section name """
|
||||
|
||||
if want_template and not config.has_option(name, 'template'):
|
||||
e = 'Error: section %s is not a template' % name
|
||||
raise PGLoader_Error, e
|
||||
|
||||
##
|
||||
# reject log and data files defaults to /tmp/<section>.rej[.log]
|
||||
if config.has_option(name, 'reject_log'):
|
||||
@ -388,7 +401,8 @@ class PGLoader:
|
||||
print 'reader.readconfig()'
|
||||
self.reader.readconfig(name, config)
|
||||
|
||||
if not self.template and self.format is None:
|
||||
if not self.template and \
|
||||
('format' not in self.__dict__ or self.format is None):
|
||||
# error only when not loading the Template part
|
||||
print 'Error: %s: format parameter needed' % name
|
||||
raise PGLoader_Error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user