File: dbf.rst

package info (click to toggle)
pgloader 3.6.10-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,060 kB
  • sloc: sql: 32,321; lisp: 14,793; makefile: 435; sh: 85; python: 26
file content (88 lines) | stat: -rw-r--r-- 2,716 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
DBF
===

This command instructs pgloader to load data from a `DBF` file. A default
set of casting rules are provided and might be overloaded and appended to by
the command.

Using advanced options and a load command file
----------------------------------------------

Here's an example with a remote HTTP source and some user defined casting
rules. The command then would be:

::

   $ pgloader dbf.load

And the contents of the ``dbf.load`` file could be inspired from the following:

::

    LOAD DBF
        FROM http://www.insee.fr/fr/methodes/nomenclatures/cog/telechargement/2013/dbf/reg2013.dbf
        INTO postgresql://user@localhost/dbname
        WITH truncate, create table
        CAST column reg2013.region to integer,
             column reg2013.tncc to smallint;


Common Clauses
--------------

Please refer to :ref:`common_clauses` for documentation about common
clauses.

DBF Source Specification: FROM
------------------------------

Filename where to load the data from. This support local files, HTTP URLs
and zip files containing a single dbf file of the same name. Fetch such a
zip file from an HTTP address is of course supported.

DBF Loading Options: WITH
-------------------------

When loading from a `DBF` file, the following options are supported:

  - *truncate*

    When this option is listed, pgloader issues a `TRUNCATE` command against
    the PostgreSQL target table before reading the data file.

  - *disable triggers*

    When this option is listed, pgloader issues an `ALTER TABLE ... DISABLE
    TRIGGER ALL` command against the PostgreSQL target table before copying
    the data, then the command `ALTER TABLE ... ENABLE TRIGGER ALL` once the
    `COPY` is done.

    This option allows loading data into a pre-existing table ignoring the
    *foreign key constraints* and user defined triggers and may result in
    invalid *foreign key constraints* once the data is loaded. Use with
    care.

  - *create table*

    When this option is listed, pgloader creates the table using the meta
    data found in the `DBF` file, which must contain a list of fields with
    their data type. A standard data type conversion from DBF to PostgreSQL
    is done.

  - *table name*

    This options expects as its value the possibly qualified name of the
    table to create.

Default DB3 Casting Rules
-------------------------

When migrating from DB3 the following Casting Rules are provided::

  type C to text using db3-trim-string
  type M to text using db3-trim-string
  type N to numeric using db3-numeric-to-pgsql-integer
  type I to numeric using db3-numeric-to-pgsql-numeric
  type L to boolean using logical-to-boolean
  type D to date using db3-date-to-pgsql-date