File: pgloader.1.html

package info (click to toggle)
pgloader 3.1.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,192 kB
  • ctags: 867
  • sloc: lisp: 6,913; makefile: 238; sh: 82; sql: 55
file content (308 lines) | stat: -rw-r--r-- 60,253 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">

    <title>pgloader</title>

    <!-- Bootstrap core CSS -->
    <link href="../dist/css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../dist/carousel.css" rel="stylesheet">
  </head>
<!-- NAVBAR
================================================== -->
  <body>
    <div class="navbar-wrapper">
      <div class="container">

        <div class="navbar navbar-inverse navbar-static-top" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="../index.html">pgloader</a>
            </div>
            <div class="navbar-collapse collapse">
              <ul class="nav navbar-nav">
                <li><a href="../index.html">Home</a></li>
                <li><a href="pgloader.1.html">Reference documentation</a></li>
                <li class="dropdown active">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Data Sources HowTos <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li class="dropdown-header">Plain Files</li>
                    <li><a href="csv.html">CSV</a></li>
                    <li><a href="fixed.html">Fixed format</a></li>
                    <li><a href="geolite.html">Geolite</a></li>
                    <li class="divider"></li>
                    <li class="dropdown-header">Databases</li>
                    <li><a href="dBase.html">dBase</a></li>
                    <li><a href="sqlite.html">SQLite</a></li>
                    <li><a href="mysql.html">MySQL</a></li>
                  </ul>
                </li>
                <li><a href="../download.html">Download</a></li>
              </ul>
            </div>
          </div>
        </div>

      </div>
    </div>

    <!-- an empty carousel -->
    <div id="myCarousel" class="carousel slide" data-ride="carousel" style="height: 100px">
      <div class="carousel-inner" style="height: 100px">
        <div class="item active" style="height: 100px">
          <img data-src="holder.js/900x100/auto/#777:#7a7a7a" style="height: 100px">
          <!-- <div class="container"> -->
          <!--   <div class="carousel-caption"> -->
          <!--     <h1>Load data into PostgreSQL. Fast.</h1> -->
          <!--     <p></p> -->
          <!--   </div> -->
          <!-- </div> -->
        </div>
      </div>
    </div><!-- /.carousel -->

    <div class="container">
      <div class="row">
        <div class="col-md-2"> </div>
        <div class="col-md-8">
<h1>pgloader(1) -- PostgreSQL data loader</h1><h2>SYNOPSIS</h2><p><code>pgloader</code> <options>... </p><h2>DESCRIPTION</h2><p>pgloader loads data from various sources into PostgreSQL. It can transform the data it reads on the fly and submit raw SQL before and after the loading.  It uses the <code>COPY</code> PostgreSQL protocol to stream the data into the server, and manages errors by filling a pair of <em>reject.dat</em> and <em>reject.log</em> files. </p><p>pgloader operates using commands which are read from files: </p><pre><code>pgloader commands.load </code></pre><h2>OPTIONS</h2><ul><li><p><code>-h</code>, <code>--help</code>: Show command usage summary and exit. </p><li><p><code>-V</code>, <code>--version</code>: Show pgloader version string and exit. </p></li><li><p><code>-v</code>, <code>--verbose</code>: Be verbose. </p></li><li><p><code>-q</code>, `--quiet: Be quiet. </p></li><li><p><code>-d</code>, <code>--debug</code>: Show debug level information messages. </p></li><li><p><code>-D</code>, <code>--root-dir</code>: Set the root working directory (default to "/tmp/pgloader"). </p></li><li><p><code>-L</code>, <code>--logfile</code>: Set the pgloader log file (default to "/tmp/pgloader.log"). </p></li><li><p><code>--log-min-messages</code>: Minimum level of verbosity needed for log message to make it to the logfile. One of critical, log, error, warning, notice, info or debug. </p></li><li><p><code>--client-min-messages</code>: Minimum level of verbosity needed for log message to make it to the console. One of critical, log, error, warning, notice, info or debug. </p></li><li><p><code>-S</code>, <code>--summary</code>: A filename where to copy the summary output. When relative, the filename is expanded into <code>*root-dir</code>. </p></li><li><p><code>-E</code>, <code>--list-encodings</code>: List known encodings in this version of pgloader. </p></li><li><p><code>-U</code>, <code>--upgrade-config</code>: Parse given files in the command line as <code>pgloader.conf</code> files with the    <code>INI</code> syntax that was in use in pgloader versions 2.x, and output the    new command syntax for pgloader on standard output. </p></li><li><p><code>-l &lt;file&gt;</code>, <code>--load-lisp-file &lt;file&gt;</code>: Specify a lisp <file>  to compile and load into the pgloader image before reading the commands, allowing to define extra transformation function. Those functions should be defined in the <code>pgloader.transforms</code> package. This option can appear more than once in the command line. </p></li><li><p><code>--self-upgrade &lt;directory&gt;</code>:</p></li></li><p>Specify a <directory>  where to find pgloader sources so that one of the very first things it does is dynamically loading-in (and compiling to machine code) another version of itself, usually a newer one like a very recent git checkout. </p></ul><p>To get the maximum amount of debug information, you can use both the <code>--verbose</code> and the <code>--debug</code> switches at the same time, which is equivalent to saying <code>--client-min-messages data</code>. Then the log messages will show the data being processed, in the cases where the code has explicit support for it. </p><h2>BATCHES AND RETRY BEHAVIOUR</h2><p>To load data to PostgreSQL, pgloader uses the <code>COPY</code> streaming protocol. While this is the faster way to load data, <code>COPY</code> has an important drawback: as soon as PostgreSQL emits an error with any bit of data sent to it, whatever the problem is, the whole data set is rejected by PostgreSQL. </p><p>To work around that, pgloader cuts the data into <em>batches</em> of 25000 rows each, so that when a problem occurs it's only impacting that many rows of data. Each batch is kept in memory while the <code>COPY</code> streaming happens, in order to be able to handle errors should some happen. </p><p>When PostgreSQL rejects the whole batch, pgloader logs the error message then isolates the bad row(s) from the accepted ones by retrying the batched rows in smaller batches. To do that, pgloader parses the <em>CONTEXT</em> error message from the failed COPY, as the message contains the line number where the error was found in the batch, as in the following example: </p><pre><code>CONTEXT: COPY errors, line 3, column b: "2006-13-11" </code></pre><p>Using that information, pgloader will reload all rows in the batch before the erroneous one, log the erroneous one as rejected, then try loading the remaining of the batch in a single attempt, which may or may not contain other erroneous data. </p><p>At the end of a load containing rejected rows, you will find two files in the <em>root-dir</em> location, under a directory named the same as the target database of your setup. The filenames are the target table, and their extensions are <code>.dat</code> for the rejected data and <code>.log</code> for the file containing the full PostgreSQL client side logs about the rejected data. </p><p>The <code>.dat</code> file is formatted in PostgreSQL the text COPY format as documented in <a href="">http://www.postgresql.org/docs/9.2/static/sql-copy.html#AEN66609</a>. </p><h2>A NOTE ABOUT PERFORMANCES</h2><p>pgloader has been developed with performances in mind, to be able to cope with ever growing needs in loading large amounts of data into PostgreSQL. </p><p>The basic architecture it uses is the old Unix pipe model, where a thread is responsible for loading the data (reading a CSV file, querying MySQL, etc) and fills pre-processed data into a queue. Another threads feeds from the queue, apply some more <em>transformations</em> to the input data and stream the end result to PostgreSQL using the COPY protocol. </p><p>When given a file that the PostgreSQL <code>COPY</code> command knows how to parse, and if the file contains no erroneous data, then pgloader will never be as fast as just using the PostgreSQL <code>COPY</code> command. </p><p>Note that while the <code>COPY</code> command is restricted to read either from its standard input or from a local file on the server's file system, the command line tool <code>psql</code> implements a <code>\copy</code> command that knows how to stream a file local to the client over the network and into the PostgreSQL server, using the same protocol as pgloader uses. </p><h2>COMMANDS</h2><p>pgloader support the following commands: </p><ul><li><code>LOAD CSV</code></li><li><code>LOAD FIXED</code></li><li><code>LOAD DBF</code></li><li><code>LOAD SQLite</code></li><li><code>LOAD MYSQL</code></li><li><code>LOAD ARCHIVE</code></li><li><code>LOAD DATABASE</code></li><li><code>LOAD MESSAGES</code></li></ul><p>The pgloader commands follow the same grammar rules. Each of them might support only a subset of the general options and provide specific options. </p><pre><code>LOAD &lt;something&gt;  
     FROM &lt;source-url&gt;  [ WITH &lt;source-options&gt; ]  
	 INTO &lt;postgresql-url&gt;  
 
[ WITH &lt;load-options&gt; ]  
 
[ SET &lt;postgresql-settings&gt; ]  
; </code></pre><p>The main clauses are the <code>LOAD</code>, <code>FROM</code>, <code>INTO</code> and <code>WITH</code> clauses that each command implements. Some command then implement the <code>SET</code> command, or some specific clauses such as the <code>CAST</code> clause. </p><h2>COMMON CLAUSES</h2><p>Some clauses are common to all commands: </p><ul><li><em>FROM</em><p>The <em>FROM</em> clause specifies where to read the data from, and each command introduces its own variant of sources. For instance, the <em>CSV</em> source supports <code>inline</code>, <code>stdin</code>, a filename, a quoted filename, and a <em>FILENAME MATCHING</em> clause (see above); whereas the <em>MySQL</em> source only supports a MySQL database URI specification. </p></li><p>In all cases, the <em>FROM</em> clause is able to read its value from an environment variable when using the form <code>GETENV 'varname'</code>. </p><li><em>INTO</em></li><p>The PostgreSQL connection URI must contains the name of the target table where to load the data into. That table must have already been created in PostgreSQL, and the name might be schema qualified. </p><p>The <em>INTO</em> target database connection URI can be parsed from the value of an environment variable when using the form <code>GETENV 'varname'</code>. </p><p>Then <em>INTO</em> option also supports an optional comma separated list of target columns, which are either the name of an input <em>field</em> or the white space separated list of the target column name, its PostgreSQL data type and a <em>USING</em> expression. </p><p>The <em>USING</em> expression can be any valid Common Lisp form and will be read with the current package set to <code>pgloader.transforms</code>, so that you can use functions defined in that package, such as functions loaded dynamically with the <code>--load</code> command line parameter. </p><p>Each <em>USING</em> expression is compiled at runtime to native code. </p><p>This feature allows pgloader to load any number of fields in a CSV file into a possibly different number of columns in the database, using custom code for that projection. </p><li><em>WITH</em><p>Set of options to apply to the command, using a global syntax of either: </p><ul><li><em>key = value</em></li><li><em>use option</em></li><li><em>do not use option</em></li></ul></li><p>See each specific command for details. </p><li><em>SET</em></li><p>This clause allows to specify session parameters to be set for all the sessions opened by pgloader. It expects a list of parameter name, the equal sign, then the single-quoted value as a comma separated list. </p><p>The names and values of the parameters are not validated by pgloader, they are given as-is to PostgreSQL. </p><li><em>BEFORE LOAD DO</em><p> You can run SQL queries against the database before loading the data  from the <code>CSV</code> file. Most common SQL queries are <code>CREATE TABLE IF NOT  EXISTS</code> so that the data can be loaded. </p></li><p> Each command must be <em>dollar-quoted</em>: it must begin and end with a  double dollar sign, <code>$$</code>. Dollar-quoted queries are then comma  separated. No extra punctuation is expected after the last SQL query. </p><li><em>BEFORE LOAD EXECUTE</em></li><p> Same behaviour as in the <em>BEFORE LOAD DO</em> clause. Allows you to read  the SQL queries from a SQL file. Implements support for PostgreSQL  dollar-quoting and the <code>\i</code> and <code>\ir</code> include facilities as in <code>psql</code>  batch mode (where they are the same thing). </p><li><em>AFTER LOAD DO</em></li><p>Same format as <em>BEFORE LOAD DO</em>, the dollar-quoted queries found in that section are executed once the load is done. That's the right time to create indexes and constraints, or re-enable triggers. </p><li><em>AFTER LOAD EXECUTE</em></li><p> Same behaviour as in the <em>AFTER LOAD DO</em> clause. Allows you to read the  SQL queries from a SQL file. Implements support for PostgreSQL  dollar-quoting and the <code>\i</code> and <code>\ir</code> include facilities as in <code>psql</code>  batch mode (where they are the same thing). </p></ul><h3>Connection String</h3><p>The <code>&lt;source-url&gt;</code> parameter is expected to be given as a <em>Connection URI</em> as documented in the PostgreSQL documentation at http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNSTRING. </p><pre><code>postgresql://[user[:password]@][netloc][:port][/dbname][?schema.table] </code></pre><p>Where: </p><ul><li><em>user</em><p>Can contain any character, including colon (<code>:</code>) which must then be doubled (<code>::</code>) and at-sign (<code>@</code>) which must then be doubled (<code>@@</code>). </p></li><p>When omitted, the <em>user</em> name defaults to the value of the <code>PGUSER</code> environment variable, and if it is unset, the value of the <code>USER</code> environment variable. </p><li><em>password</em></li><p>Can contain any character, including that at sign (<code>@</code>) which must then be doubled (<code>@@</code>). To leave the password empty, when the <em>user</em> name ends with at at sign, you then have to use the syntax user:@. </p><p>When omitted, the <em>password</em> defaults to the value of the <code>PGPASSWORD</code> environment variable if it is set, otherwise the password is left unset. </p><li><em>netloc</em><p>Can be either a hostname in dotted notation, or an ipv4, or an Unix domain socket path. Empty is the default network location, under a system providing <em>unix domain socket</em> that method is preferred, otherwise the <em>netloc</em> default to <code>localhost</code>. </p></li><p>It's possible to force the <em>unix domain socket</em> path by using the syntax <code>unix:/path/to/where/the/socket/file/is</code>, so to force a non default socket path and a non default port, you would have: </p><pre><code>postgresql://unix:/tmp:54321/dbname </code></pre><p>The <em>netloc</em> defaults to the value of the <code>PGHOST</code> environment variable, and if it is unset, to either the default <code>unix</code> socket path when running on a Unix system, and <code>localhost</code> otherwise. </p><li><em>dbname</em></li><p>Should be a proper identifier (letter followed by a mix of letters, digits and the punctuation signs comma (<code>,</code>), dash (<code>-</code>) and underscore (<code>_</code>). </p><p>When omitted, the <em>dbname</em> defaults to the value of the environment variable <code>PGDATABASE</code>, and if that is unset, to the <em>user</em> value as determined above. </p><li>The only optional parameter should be a possibly qualified table name.</li></ul><h3>Regular Expressions</h3><p>Several clauses listed in the following accept <em>regular expressions</em> with the following input rules: </p><ul><li><p>A regular expression begins with a tilde sign (<code>~</code>),</p></li><li><p>is then followed with an opening sign,</p></li><li><p>then any character is allowed and considered part of the regular expression, except for the closing sign, </p></li><li><p>then a closing sign is expected.</p></li></ul><p>The opening and closing sign are allowed by pair, here's the complete list of allowed delimiters: </p><pre><code>~//  
~[]  
~{}  
~()  
~&lt;&gt;  
~""  
~''  
~||  
~## </code></pre><p>Pick the set of delimiters that don't collide with the <em>regular expression</em> you're trying to input. If your expression is such that none of the solutions allow you to enter it, the places where such expressions are allowed should allow for a list of expressions. </p><h3>Comments</h3><p>Any command may contain comments, following those input rules: </p><ul><li><p>the <code>--</code> delimiter begins a comment that ends with the end of the current line, </p></li><li><p>the delimiters <code>/*</code> and <code>*/</code> respectively start and end a comment, which can be found in the middle of a command or span several lines. </p></li></ul><p>Any place where you could enter a <em>whitespace</em> will accept a comment too. </p><h3>Batch behaviour options</h3><p>All pgloader commands have support for a <em>WITH</em> clause that allows for specifying options. Some options are generic and accepted by all commands, such as the <em>batch behaviour options</em>, and some options are specific to a data source kind, such as the CSV <em>skip header</em> option. </p><p>The global batch behaviour options are: </p><ul><li><em>batch rows</em><p>Takes a numeric value as argument, used as the maximum number of rows allowed in a batch. The default is <code>25 000</code> and can be changed to try having better performances characteristics or to control pgloader memory usage; </p></li><li><em>batch size</em><p>Takes a memory unit as argument, such as <em>20 MB</em>, its default value. Accepted multipliers are <em>kB</em>, <em>MB</em>, <em>GB</em>, <em>TB</em> and <em>PB</em>. The case is important so as not to be confused about bits versus bytes, we're only talking bytes here. </p></li><li><em>batch concurrency</em><p>Takes a numeric value as argument, defaults to <code>10</code>. That's the number of batches that pgloader is allows to build in memory, even when only a single batch at a time might be sent to PostgreSQL. </p></li><p>Supporting more than a single batch being sent at a time is on the TODO list of pgloader, but is not implemented yet. This option is about controlling the memory needs of pgloader as a trade-off to the performances characteristics, and not about parallel activity of pgloader. </p></ul><p>Other options are specific to each input source, please refer to specific parts of the documentation for their listing and covering. </p><p>A batch is then closed as soon as either the <em>batch rows</em> or the <em>batch size</em> threshold is crossed, whichever comes first. In cases when a batch has to be closed because of the <em>batch size</em> setting, a <em>debug</em> level log message is printed with how many rows did fit in the <em>oversized</em> batch. </p><h2>LOAD CSV</h2><p>This command instructs pgloader to load data from a <code>CSV</code> file. Here's an example: </p><pre><code>LOAD CSV  
   FROM 'GeoLiteCity-Blocks.csv' WITH ENCODING iso-646-us  
        HAVING FIELDS  
        (  
           startIpNum, endIpNum, locId  
        )  
   INTO postgresql://user@localhost:54393/dbname?geolite.blocks  
        TARGET COLUMNS  
        (  
           iprange ip4r using (ip-range startIpNum endIpNum),  
           locId  
        )  
   WITH truncate,  
        skip header = 2,  
        fields optionally enclosed by '"',  
        fields escaped by backslash-quote,  
        fields terminated by '\t'  
 
    SET work_mem to '32 MB', maintenance_work_mem to '64 MB'; </code></pre><p>The <code>csv</code> format command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>Filename where to load the data from. Accepts an <em>ENCODING</em> option. Use the <code>--list-encodings</code> option to know which encoding names are supported. </p></li><p>The filename may be enclosed by single quotes, and could be one of the following special values: </p><ul><li><em>inline</em><p>The data is found after the end of the parsed commands. Any number of empty lines between the end of the commands and the beginning of the data is accepted. </p></li><li><em>stdin</em><p>Reads the data from the standard input stream. </p></li><li><em>FILENAMES MATCHING</em><p>The whole <em>matching</em> clause must follow the following rule: </p><pre><code>[ ALL FILENAMES | [ FIRST ] FILENAME ]  
MATCHING regexp  
[ IN DIRECTORY '...' ] </code></pre></li><p>The <em>matching</em> clause applies given <em>regular expression</em> (see above for exact syntax, several options can be used here) to filenames. It's then possible to load data from only the first match of all of them. </p><p>The optional <em>IN DIRECTORY</em> clause allows specifying which directory to walk for finding the data files, and can be either relative to where the command file is read from, or absolute. The given directory must exists. </p></ul><p>The <em>FROM</em> option also supports an optional comma separated list of <em>field</em> names describing what is expected in the <code>CSV</code> data file, optionally introduced by the clause <code>HAVING FIELDS</code>. </p><p>Each field name can be either only one name or a name following with specific reader options for that field. Supported per-field reader options are: </p><ul><li><em>terminated by</em><p>See the description of <em>field terminated by</em> below. </p></li><p>The processing of this option is not currently implemented. </p><li><em>date format</em></li><p>When the field is expected of the date type, then this option allows to specify the date format used in the file. </p><p>The processing of this option is not currently implemented. </p><li><em>null if</em><p>This option takes an argument which is either the keyword <em>blanks</em> or a double-quoted string. </p></li><p>When <em>blanks</em> is used and the field value that is read contains only space characters, then it's automatically converted to an SQL <code>NULL</code> value. </p><p>When a double-quoted string is used and that string is read as the field value, then the field value is automatically converted to an SQL <code>NULL</code> value. </p></ul><li><em>WITH</em><p>When loading from a <code>CSV</code> file, the following options are supported: </p><ul><li><em>truncate</em><p>When this option is listed, pgloader issues a <code>TRUNCATE</code> command against the PostgreSQL target table before reading the data file. </p></li><li><em>skip header</em><p>Takes a numeric value as argument. Instruct pgloader to skip that many lines at the beginning of the input file. </p></li><li><em>trim unquoted blanks</em><p>When reading unquoted values in the <code>CSV</code> file, remove the blanks found in between the separator and the value. That behaviour is the default. </p></li><li><em>keep unquoted blanks</em><p>When reading unquoted values in the <code>CSV</code> file, keep blanks found in between the separator and the value. </p></li><li><em>fields optionally enclosed by</em><p>Takes a single character as argument, which must be found inside single quotes, and might be given as the printable character itself, the special value \t to denote a tabulation character, or <code>0x</code> then an hexadecimal value read as the ASCII code for the character. </p></li><p>This character is used as the quoting character in the <code>CSV</code> file, and defaults to double-quote. </p><li><em>fields not enclosed</em></li><p>By default, pgloader will use the double-quote character as the enclosing character. If you have a CSV file where fields are not enclosed and are using double-quote as an expected ordinary character, then use the option <em>fields not enclosed</em> for the CSV parser to accept those values. </p><li><em>fields escaped by</em></li><p>Takes either the special value <em>backslash-quote</em> or <em>double-quote</em>. This value is used to recognize escaped field separators when they are to be found within the data fields themselves. Defaults to <em>double-quote</em>. </p><li><em>fields terminated by</em></li><p>Takes a single character as argument, which must be found inside single quotes, and might be given as the printable character itself, the special value \t to denote a tabulation character, or <code>0x</code> then an hexadecimal value read as the ASCII code for the character. </p><p>This character is used as the <em>field separator</em> when reading the <code>CSV</code> data. </p><li><em>lines terminated by</em><p>Takes a single character as argument, which must be found inside single quotes, and might be given as the printable character itself, the special value \t to denote a tabulation character, or <code>0x</code> then an hexadecimal value read as the ASCII code for the character. </p></li><p>This character is used to recognize <em>end-of-line</em> condition when reading the <code>CSV</code> data. </p></ul></li></ul><h2>LOAD FIXED COLS</h2><p>This command instructs pgloader to load data from a text file containing columns arranged in a <em>fixed size</em> manner. Here's an example: </p><pre><code>LOAD FIXED  
     FROM inline (a 0 10, b 10 8, c 18 8, d 26 17)  
     INTO postgresql:///pgloader?fixed  
          (  
             a, b,  
             c time using (time-with-no-separator c),  
             d  
          )  
 
     WITH truncate  
 
      SET client_encoding to 'latin1',  
          work_mem to '14MB',  
          standard_conforming_strings to 'on'  
 
BEFORE LOAD DO  
     $$ drop table if exists fixed; $$,  
     $$ create table fixed (  
         a integer,  
         b date,  
         c time,  
         d text  
        );  
     $$;  
 
 01234567892008052011431250firstline  
    01234562008052115182300left blank-padded  
 12345678902008052208231560another line </code></pre><p>The <code>fixed</code> format command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>Filename where to load the data from. Accepts an <em>ENCODING</em> option. Use the <code>--list-encodings</code> option to know which encoding names are supported. </p></li><p>The filename may be enclosed by single quotes, and could be one of the following special values: </p><ul><li><em>inline</em><p>The data is found after the end of the parsed commands. Any number of empty lines between the end of the commands and the beginning of the data is accepted. </p></li><li><em>stdin</em><p>Reads the data from the standard input stream. </p></li></ul><p>The <em>FROM</em> option also supports an optional comma separated list of <em>field</em> names describing what is expected in the <code>FIXED</code> data file. </p><p>Each field name is composed of the field name followed with specific reader options for that field. Supported per-field reader options are the following, where only <em>start</em> and <em>length</em> are required. </p><ul><li><em>start</em><p>Position in the line where to start reading that field's value. Can be entered with decimal digits or <code>0x</code> then hexadecimal digits. </p></li><li><em>length</em><p>How many bytes to read from the <em>start</em> position to read that field's value. Same format as <em>start</em>. </p></li><li><em>terminated by</em><p>See the description of <em>field terminated by</em> below. </p></li><p>The processing of this option is not currently implemented. </p><li><em>date format</em></li><p>When the field is expected of the date type, then this option allows to specify the date format used in the file. </p><p>The processing of this option is not currently implemented. </p><li><em>null if</em><p>This option takes an argument which is either the keyword <em>blanks</em> or a double-quoted string. </p></li><p>When <em>blanks</em> is used and the field value that is read contains only space characters, then it's automatically converted to an SQL <code>NULL</code> value. </p><p>When a double-quoted string is used and that string is read as the field value, then the field value is automatically converted to an SQL <code>NULL</code> value. </p></ul><li><em>WITH</em><p>When loading from a <code>CSV</code> file, the following options are supported: </p><ul><li><em>truncate</em><p>When this option is listed, pgloader issues a <code>TRUNCATE</code> command against the PostgreSQL target table before reading the data file. </p></li><li><em>skip header</em><p>Takes a numeric value as argument. Instruct pgloader to skip that many lines at the beginning of the input file. </p></li></ul></li></ul><h2>LOAD DBF</h2><p>This command instructs pgloader to load data from a <code>DBF</code> file. Here's an example: </p><pre><code>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; </code></pre><p>The <code>dbf</code> format command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>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. </p></li><li><em>WITH</em><p>When loading from a <code>DBF</code> file, the following options are supported: </p><ul><li><em>truncate</em><p>When this option is listed, pgloader issues a <code>TRUNCATE</code> command against the PostgreSQL target table before reading the data file. </p></li><li><em>create table</em><p>When this option is listed, pgloader creates the table using the meta data found in the <code>DBF</code> file, which must contain a list of fields with their data type. A standard data type conversion from DBF to PostgreSQL is done. </p></li><li><em>table name</em><p>This options expects as its value the possibly qualified name of the table to create. </p></li></ul></li></ul><h2>LOAD IXF</h2><p>This command instructs pgloader to load data from an IBM <code>IXF</code> file. Here's an example: </p><pre><code>LOAD IXF  
    FROM data/nsitra.test1.ixf  
    INTO postgresql:///pgloader?nsitra.test1  
    WITH truncate, create table  
 
  BEFORE LOAD DO  
   $$ create schema if not exists nsitra; $$,  
   $$ drop table if exists nsitra.test1; $$; </code></pre><p>The <code>ixf</code> format command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>Filename where to load the data from. This support local files, HTTP URLs and zip files containing a single ixf file of the same name. Fetch such a zip file from an HTTP address is of course supported. </p></li><li><em>WITH</em><p>When loading from a <code>IXF</code> file, the following options are supported: </p><ul><li><em>truncate</em><p>When this option is listed, pgloader issues a <code>TRUNCATE</code> command against the PostgreSQL target table before reading the data file. </p></li><li><em>create table</em><p>When this option is listed, pgloader creates the table using the meta data found in the <code>DBF</code> file, which must contain a list of fields with their data type. A standard data type conversion from DBF to PostgreSQL is done. </p></li><li><em>table name</em><p>This options expects as its value the possibly qualified name of the table to create. </p></li></ul></li></ul><h2>LOAD ARCHIVE</h2><p>This command instructs pgloader to load data from one or more files contained in an archive. Currently the only supported archive format is <em>ZIP</em>, and the archive might be downloaded from an <em>HTTP</em> URL. </p><p>Here's an example: </p><pre><code>LOAD ARCHIVE  
   FROM /Users/dim/Downloads/GeoLiteCity-latest.zip  
   INTO postgresql:///ip4r  
 
   BEFORE LOAD DO  
     $$ create extension if not exists ip4r; $$,  
     $$ create schema if not exists geolite; $$,  
     $$ create table if not exists geolite.location  
       (  
          locid      integer primary key,  
          country    text,  
          region     text,  
          city       text,  
          postalcode text,  
          location   point,  
          metrocode  text,  
          areacode   text  
       );  
     $$,  
     $$ create table if not exists geolite.blocks  
       (  
          iprange    ip4r,  
          locid      integer  
       );  
     $$,  
     $$ drop index if exists geolite.blocks_ip4r_idx; $$,  
     $$ truncate table geolite.blocks, geolite.location cascade; $$  
 
   LOAD CSV  
        FROM FILENAME MATCHING ~/GeoLiteCity-Location.csv/  
             WITH ENCODING iso-8859-1  
             (  
                locId,  
                country,  
                region     null if blanks,  
                city       null if blanks,  
                postalCode null if blanks,  
                latitude,  
                longitude,  
                metroCode  null if blanks,  
                areaCode   null if blanks  
             )  
        INTO postgresql:///ip4r?geolite.location  
             (  
                locid,country,region,city,postalCode,  
                location point using (format nil "(~a,~a)" longitude latitude),  
                metroCode,areaCode  
             )  
        WITH skip header = 2,  
             fields optionally enclosed by '"',  
             fields escaped by double-quote,  
             fields terminated by ','  
 
  AND LOAD CSV  
        FROM FILENAME MATCHING ~/GeoLiteCity-Blocks.csv/  
             WITH ENCODING iso-8859-1  
             (  
                startIpNum, endIpNum, locId  
             )  
        INTO postgresql:///ip4r?geolite.blocks  
             (  
                iprange ip4r using (ip-range startIpNum endIpNum),  
                locId  
             )  
        WITH skip header = 2,  
             fields optionally enclosed by '"',  
             fields escaped by double-quote,  
             fields terminated by ','  
 
   FINALLY DO  
     $$ create index blocks_ip4r_idx on geolite.blocks using gist(iprange); $$; </code></pre><p>The <code>archive</code> command accepts the following clauses and options: </p><ul><li><em>FROM</em><p> Filename or HTTP URI where to load the data from. When given an HTTP  URL the linked file will get downloaded locally before processing. </p></li><p> If the file is a <code>zip</code> file, the command line utility <code>unzip</code> is used  to expand the archive into files in <code>$TMPDIR</code>, or <code>/tmp</code> if <code>$TMPDIR</code>  is unset or set to a non-existing directory. </p><p> Then the following commands are used from the top level directory where  the archive has been expanded. </p><li>command [ <em>AND</em> command ... ]<p> A series of commands against the contents of the archive, at the moment  only <code>CSV</code>,<code>'FIXED</code> and <code>DBF</code> commands are supported. </p></li><p> Note that commands are supporting the clause <em>FROM FILENAME MATCHING</em>  which allows the pgloader command not to depend on the exact names of  the archive directories. </p><p> The same clause can also be applied to several files with using the  spelling <em>FROM ALL FILENAMES MATCHING</em> and a regular expression. </p><p> The whole <em>matching</em> clause must follow the following rule: </p><pre><code> FROM [ ALL FILENAMES | [ FIRST ] FILENAME ] MATCHING </code></pre><li><em>FINALLY DO</em><p> SQL Queries to run once the data is loaded, such as <code>CREATE INDEX</code>. </p></li></ul><h2>LOAD MYSQL DATABASE</h2><p>This command instructs pgloader to load data from a database connection. The only supported database source is currently <em>MySQL</em>, and pgloader supports dynamically converting the schema of the source database and the indexes building. </p><p>A default set of casting rules are provided and might be overloaded and appended to by the command. </p><p>Here's an example: </p><pre><code>LOAD DATABASE  
     FROM      mysql://root@localhost/sakila  
     INTO postgresql://localhost:54393/sakila  
 
 WITH include drop, create tables, create indexes, reset sequences  
 
  SET maintenance_work_mem to '128MB',  
      work_mem to '12MB',  
      search_path to 'sakila'  
 
 CAST type datetime to timestamptz drop default drop not null using zero-dates-to-null,  
      type date drop not null drop default using zero-dates-to-null,  
      -- type tinyint to boolean using tinyint-to-boolean,  
      type year to integer  
 
 MATERIALIZE VIEWS film_list, staff_list  
 
 -- INCLUDING ONLY TABLE NAMES MATCHING ~/film/, 'actor'  
 -- EXCLUDING TABLE NAMES MATCHING ~&lt;ory&gt;  
 -- DECODING TABLE NAMES MATCHING ~/messed/, ~/encoding/ AS utf8  
 
 BEFORE LOAD DO  
 $$ create schema if not exists sakila; $$; </code></pre><p>The <code>database</code> command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>Must be a connection URL pointing to a MySQL database. At the moment only MySQL is supported as a pgloader source. </p></li><p>If the connection URI contains a table name, then only this table is migrated from MySQL to PostgreSQL. </p><li><em>WITH</em></li><p>When loading from a <code>MySQL</code> database, the following options are supported: </p><ul><li><em>include drop</em><p>When this option is listed, pgloader drop in the PostgreSQL connection all the table whose names have been found in the MySQL database. This option allows for using the same command several times in a row until you figure out all the options, starting automatically from a clean environment. </p></li><li><em>include no drop</em><p>When this option is listed, pgloader will not include any <code>DROP</code> statement when loading the data. </p></li><li><em>truncate</em><p>When this option is listed, pgloader issue the <code>TRUNCATE</code> command against each PostgreSQL table just before loading data into it. </p></li><li><em>no truncate</em><p>When this option is listed, pgloader issues no <code>TRUNCATE</code> command. </p></li><li><em>create tables</em><p>When this option is listed, pgloader creates the table using the meta data found in the <code>MySQL</code> file, which must contain a list of fields with their data type. A standard data type conversion from DBF to PostgreSQL is done. </p></li><li><em>create no tables</em><p>When this option is listed, pgloader skips the creation of table before lading data, target tables must then already exist. </p></li><li><em>create indexes</em><p>When this option is listed, pgloader gets the definitions of all the indexes found in the MySQL database and create the same set of index definitions against the PostgreSQL database. </p></li><li><em>create no indexes</em><p>When this option is listed, pgloader skips the creating indexes. </p></li><li><em>foreign keys</em><p>When this option is listed, pgloader gets the definitions of all the foreign keys found in the MySQL database and create the same set of foreign key definitions against the PostgreSQL database. </p></li><li><em>no foreign keys</em><p>When this option is listed, pgloader skips creating foreign keys. </p></li><li><em>reset sequences</em><p>When this option is listed, at the end of the data loading and after the indexes have all been created, pgloader resets all the PostgreSQL sequences created to the current maximum value of the column they are attached to. </p></li><p>The options <em>schema only</em> and <em>data only</em> have no effects on this option. </p><li><em>reset no sequences</em></li><p>When this option is listed, pgloader skips resetting sequences after the load. </p><p>The options <em>schema only</em> and <em>data only</em> have no effects on this option. </p><li><em>downcase identifiers</em><p>When this option is listed, pgloader converts all MySQL identifiers (table names, index names, column names) to <em>downcase</em>, except for PostgreSQL <em>reserved</em> keywords. </p></li><p>The PostgreSQL <em>reserved</em> keywords are determined dynamically by using the system function <code>pg_get_keywords()</code>. </p><li><em>quote identifiers</em></li><p>When this option is listed, pgloader quotes all MySQL identifiers so that their case is respected. Note that you will then have to do the same thing in your application code queries. </p><li><em>schema only</em></li><p>When this option is listed pgloader refrains from migrating the data over. Note that the schema in this context includes the indexes when the option <em>create indexes</em> has been listed. </p><li><em>data only</em></li><p>When this option is listed pgloader only issues the <code>COPY</code> statements, without doing any other processing. </p></ul><li><em>CAST</em><p>The cast clause allows to specify custom casting rules, either to overload the default casting rules or to amend them with special cases. </p></li><p>A casting rule is expected to follow one of the forms: </p><pre><code>type &lt;mysql-type-name&gt; [ &lt;guard&gt; ... ] to &lt;pgsql-type-name&gt; [ &lt;option&gt; ... ]  
column &lt;table-name&gt;.&lt;column-name&gt; [ &lt;guards&gt; ] to ... </code></pre><p>It's possible for a <em>casting rule</em> to either match against a MySQL data type or against a given <em>column name</em> in a given <em>table name</em>. That flexibility allows to cope with cases where the type <code>tinyint</code> might have been used as a <code>boolean</code> in some cases but as a <code>smallint</code> in others. </p><p>The <em>casting rules</em> are applied in order, the first match prevents following rules to be applied, and user defined rules are evaluated first. </p><p>The supported guards are: </p><ul><li><em>when default 'value'</em><p>The casting rule is only applied against MySQL columns of the source type that have given <em>value</em>, which must be a single-quoted or a double-quoted string. </p></li><li><em>when typemod expression</em><p>The casting rule is only applied against MySQL columns of the source type that have a <em>typemod</em> value matching the given <em>typemod expression</em>. The <em>typemod</em> is separated into its <em>precision</em> and <em>scale</em> components. </p></li><p>Example of a cast rule using a <em>typemod</em> guard: </p><pre><code>type char when (= precision 1) to char keep typemod </code></pre><p>This expression casts MySQL <code>char(1)</code> column to a PostgreSQL column of type <code>char(1)</code> while allowing for the general case <code>char(N)</code> will be converted by the default cast rule into a PostgreSQL type <code>varchar(N)</code>. </p></ul><p>The supported casting options are: </p><ul><li><em>drop default</em>, <em>keep default</em><p>When the option <em>drop default</em> is listed, pgloader drops any existing default expression in the MySQL database for columns of the source type from the <code>CREATE TABLE</code> statement it generates. </p></li><p>The spelling <em>keep default</em> explicitly prevents that behaviour and can be used to overload the default casting rules. </p><li><em>drop not null</em>, <em>keep not null</em></li><p>When the option <em>drop not null</em> is listed, pgloader drops any existing <code>NOT NULL</code> constraint associated with the given source MySQL datatype when it creates the tables in the PostgreSQL database. </p><p>The spelling <em>keep not null</em> explicitly prevents that behaviour and can be used to overload the default casting rules. </p><li><em>drop typemod</em>, <em>keep typemod</em><p>When the option <em>drop typemod</em> is listed, pgloader drops any existing <em>typemod</em> definition (e.g. <em>precision</em> and <em>scale</em>) from the datatype definition found in the MySQL columns of the source type when it created the tables in the PostgreSQL database. </p></li><p>The spelling <em>keep typemod</em> explicitly prevents that behaviour and can be used to overload the default casting rules. </p><li><em>using</em></li><p>This option takes as its single argument the name of a function to be found in the <code>pgloader.transforms</code> Common Lisp package. See above for details. </p><p>It's possible to augment a default cast rule (such as one that applies against <code>ENUM</code> data type for example) with a <em>transformation function</em> by omitting entirely the <code>type</code> parts of the casting rule, as in the following example: </p><pre><code>column enumerate.foo using empty-string-to-null </code></pre></ul><li><em>MATERIALIZE VIEWS</em><p>This clause allows you to implement custom data processing at the data source by providing a <em>view definition</em> against which pgloader will query the data. It's not possible to just allow for plain <code>SQL</code> because we want to know a lot about the exact data types of each column involved in the query output. </p></li><p>This clause expect a comma separated list of view definitions, each one being either the name of an existing view in your database or the following expression: </p><p>  <em>name</em> <code>AS</code> <code>$$</code> <em>sql query</em> <code>$$</code> </p><p>The <em>name</em> and the <em>sql query</em> will be used in a <code>CREATE VIEW</code> statement at the beginning of the data loading, and the resulting view will then be dropped at the end of the data loading. </p><li><em>MATERIALIZE ALL VIEWS</em><p>Same behaviour as <em>MATERIALIZE VIEWS</em> using the dynamic list of views as returned by MySQL rather than asking the user to specify the list. </p></li><li><em>INCLUDING ONLY TABLE NAMES MATCHING</em><p>Introduce a comma separated list of table names or <em>regular expression</em> used to limit the tables to migrate to a sublist. </p></li><p>Example: </p><pre><code>INCLUDING ONLY TABLE NAMES MATCHING ~/film/, 'actor' </code></pre><li><em>EXCLUDING TABLE NAMES MATCHING</em><p>Introduce a comma separated list of table names or <em>regular expression</em> used to exclude table names from the migration. This filter only applies to the result of the <em>INCLUDING</em> filter. </p><pre><code>EXCLUDING TABLE NAMES MATCHING ~&lt;ory&gt; </code></pre></li><li><em>DECODING TABLE NAMES MATCHING</em><p>Introduce a comma separated list of table names or <em>regular expressions</em> used to force the encoding to use when processing data from MySQL. If the data encoding known to you is different from MySQL's idea about it, this is the option to use. </p><pre><code>DECODING TABLE NAMES MATCHING ~/messed/, ~/encoding/ AS utf8 </code></pre></li><p>You can use as many such rules as you need, all with possibly different encodings. </p></ul><h3>LIMITATIONS</h3><p>The <code>database</code> command currently only supports MySQL source database and has the following limitations: </p><ul><li>Views are not migrated,<p>Supporting views might require implementing a full SQL parser for the MySQL dialect with a porting engine to rewrite the SQL against PostgreSQL, including renaming functions and changing some constructs. </p></li><p>While it's not theoretically impossible, don't hold your breath. </p><li>Triggers are not migrated</li><p>The difficulty of doing so is not yet assessed. </p><li><code>ON UPDATE CURRENT_TIMESTAMP</code> is currently not migrated</li><p>It's simple enough to implement, just not on the priority list yet. </p><li>Of the geometric datatypes, only the <code>POINT</code> database has been covered. The other ones should be easy enough to implement now, it's just not done yet. </li></ul><h3>DEFAULT MySQL CASTING RULES</h3><p>When migrating from MySQL the following Casting Rules are provided: </p><p>Numbers: </p><ul><li>type int with extra auto_increment to serial when (&lt; precision 10)</li><li>type int with extra auto_increment to bigserial when (&lt;= 10 precision)</li><li>type int to int       when  (&lt; precision 10)</li><li>type int to bigint    when  (&lt;= 10 precision)</li><li>type smallint with extra auto_increment to serial</li><li><p>type bigint   with extra auto_increment to bigserial</p></li><li><p>type tinyint to boolean when (= 1 precision) using tinyint-to-boolean</p></li><li><p>type tinyint to smallint   drop typemod</p></li><li>type smallint to smallint  drop typemod</li><li>type mediumint to integer  drop typemod</li><li>type integer to integer    drop typemod</li><li>type float to float        drop typemod</li><li>type bigint to bigint      drop typemod</li><li><p>type double to double precision drop typemod</p></li><li><p>type numeric to numeric keep typemod</p></li><li>type decimal to decimal keep typemod</li></ul><p>Texts: </p><ul><li>type char       to varchar keep typemod</li><li>type varchar    to text</li><li>type tinytext   to text</li><li>type text       to text</li><li>type mediumtext to text</li><li>type longtext   to text</li></ul><p>Binary: </p><ul><li>type binary     to bytea</li><li>type varbinary  to bytea</li><li>type tinyblob   to bytea</li><li>type blob       to bytea</li><li>type mediumblob to bytea</li><li>type longblob   to bytea</li></ul><p>Date: </p><ul><li><p>type datetime when default "0000-00-00 00:00:00" and not null to timestamptz drop not null drop default using zero-dates-to-null </p></li><li><p>type datetime when default "0000-00-00 00:00:00" to timestamptz drop default using zero-dates-to-null </p></li><li><p>type timestamp when default "0000-00-00 00:00:00" and not null to timestamptz drop not null drop default using zero-dates-to-null </p></li><li><p>type timestamp when default "0000-00-00 00:00:00" to timestamptz drop default using zero-dates-to-null </p></li><li><p>type date when default "0000-00-00" to date drop default using zero-dates-to-null </p></li><li><p>type date to date</p></li><li>type datetime to timestamptz</li><li>type timestamp to timestamptz</li><li>type year to integer drop typemod</li></ul><p>Geometric: </p><ul><li>type point to point using pgloader.transforms::convert-mysql-point</li></ul><p>Enum types are declared inline in MySQL and separately with a <code>CREATE TYPE</code> command in PostgreSQL, so each column of Enum Type is converted to a type named after the table and column names defined with the same labels in the same order. </p><p>When the source type definition is not matched in the default casting rules nor in the casting rules provided in the command, then the type name with the typemod is used. </p><h2>LOAD SQLite DATABASE</h2><p>This command instructs pgloader to load data from a SQLite file. Automatic discovery of the schema is supported, including build of the indexes. </p><p>Here's an example: </p><pre><code>load database  
     from sqlite:///Users/dim/Downloads/lastfm_tags.db  
     into postgresql:///tags  
 
 with include drop, create tables, create indexes, reset sequences  
 
  set work_mem to '16MB', maintenance_work_mem to '512 MB'; </code></pre><p>The <code>sqlite</code> command accepts the following clauses and options: </p><ul><li><em>FROM</em><p>Path or HTTP URL to a SQLite file, might be a <code>.zip</code> file. </p></li><li><em>WITH</em><p>When loading from a <code>SQLite</code> database, the following options are supported: </p><ul><li><em>include drop</em><p>When this option is listed, pgloader drop in the PostgreSQL connection all the table whose names have been found in the SQLite database. This option allows for using the same command several times in a row until you figure out all the options, starting automatically from a clean environment. </p></li><li><em>include no drop</em><p>When this option is listed, pgloader will not include any <code>DROP</code> statement when loading the data. </p></li><li><em>truncate</em><p>When this option is listed, pgloader issue the <code>TRUNCATE</code> command against each PostgreSQL table just before loading data into it. </p></li><li><em>no truncate</em><p>When this option is listed, pgloader issues no <code>TRUNCATE</code> command. </p></li><li><em>create tables</em><p>When this option is listed, pgloader creates the table using the meta data found in the <code>SQLite</code> file, which must contain a list of fields with their data type. A standard data type conversion from DBF to PostgreSQL is done. </p></li><li><em>create no tables</em><p>When this option is listed, pgloader skips the creation of table before lading data, target tables must then already exist. </p></li><li><em>create indexes</em><p> When this option is listed, pgloader gets the definitions of all  the indexes found in the SQLite database and create the same set of  index definitions against the PostgreSQL database. </p></li><li><em>create no indexes</em><p>When this option is listed, pgloader skips the creating indexes. </p></li><li><em>reset sequences</em><p>When this option is listed, at the end of the data loading and after the indexes have all been created, pgloader resets all the PostgreSQL sequences created to the current maximum value of the column they are attached to. </p></li><li><em>reset no sequences</em><p>When this option is listed, pgloader skips resetting sequences after the load. </p></li><p>The options <em>schema only</em> and <em>data only</em> have no effects on this option. </p><li><em>schema only</em></li><p>When this option is listed pgloader will refrain from migrating the data over. Note that the schema in this context includes the indexes when the option <em>create indexes</em> has been listed. </p><li><em>data only</em></li><p>When this option is listed pgloader only issues the <code>COPY</code> statements, without doing any other processing. </p><li><em>encoding</em></li><p>This option allows to control which encoding to parse the SQLite text data with. Defaults to UTF-8. </p></ul></li><li><em>INCLUDING ONLY TABLE NAMES MATCHING</em><p>Introduce a comma separated list of table names or <em>regular expression</em> used to limit the tables to migrate to a sublist. </p></li><p>Example: </p><pre><code>INCLUDING ONLY TABLE NAMES MATCHING ~/film/, 'actor' </code></pre><li><em>EXCLUDING TABLE NAMES MATCHING</em><p>Introduce a comma separated list of table names or <em>regular expression</em> used to exclude table names from the migration. This filter only applies to the result of the <em>INCLUDING</em> filter. </p><pre><code>EXCLUDING TABLE NAMES MATCHING ~&lt;ory&gt; </code></pre></li></ul><h2>TRANSFORMATION FUNCTIONS</h2><p>Some data types are implemented in a different enough way that a transformation function is necessary. This function must be written in <code>Common lisp</code> and is searched in the <code>pgloader.transforms</code> package. </p><p>Some default transformation function are provided with pgloader, and you can use the <code>--load</code> command line option to load and compile your own lisp file into pgloader at runtime. For your functions to be found, remember to begin your lisp file with the following form: </p><pre><code>(in-package #:pgloader.transforms) </code></pre><p>The provided transformation functions are: </p><ul><li><em>zero-dates-to-null</em><p>When the input date is all zeroes, return <code>nil</code>, which gets loaded as a PostgreSQL <code>NULL</code> value. </p></li><li><em>date-with-no-separator</em><p>Applies <em>zero-dates-to-null</em> then transform the given date into a format that PostgreSQL will actually process: </p><pre><code>In:  "20041002152952"  
Out: "2004-10-02 15:29:52" </code></pre></li><li><em>tinyint-to-boolean</em><p>As MySQL lacks a proper boolean type, <em>tinyint</em> is often used to implement that. This function transforms <code>0</code> to <code>'false'</code> and anything else to <code>'true</code>'. </p></li><li><em>int-to-ip</em><p>Convert an integer into a dotted representation of an ip4. </p><pre><code>In:  18435761  
Out: "1.25.78.177" </code></pre></li><li><em>ip-range</em><p>Converts a couple of integers given as strings into a range of ip4. </p><pre><code>In:  "16825344" "16825599"  
Out: "1.0.188.0-1.0.188.255" </code></pre></li><li><em>convert-mysql-point</em><p>Converts from the <code>astext</code> representation of points in MySQL to the PostgreSQL representation. </p><pre><code>In:  "POINT(48.5513589 7.6926827)"  
Out: "(48.5513589,7.6926827)" </code></pre></li><li><em>float-to-string</em><p>Converts a Common Lisp float into a string suitable for a PostgreSQL float: </p><pre><code>In:  100.0d0  
Out: "100.0" </code></pre></li><li><em>set-to-enum-array</em><p>Converts a string representing a MySQL SET into a PostgreSQL Array of Enum values from the set. </p><pre><code>In: "foo,bar"  
Out: "{foo,bar}" </code></pre></li><li><em>right-trimg</em><p>Remove whitespace at end of string. </p></li><li><em>byte-vector-to-bytea</em><p>Transform a simple array of unsigned bytes to the PostgreSQL bytea Hex Format representation as documented at http://www.postgresql.org/docs/9.3/interactive/datatype-binary.html </p></li></ul><h2>LOAD MESSAGES</h2><p>This command is still experimental and allows receiving messages via UDP using a syslog like format, and, depending on rule matching, loads named portions of the data stream into a destination table. </p><pre><code>LOAD MESSAGES  
    FROM syslog://localhost:10514/  
 
 WHEN MATCHES rsyslog-msg IN apache  
  REGISTERING timestamp, ip, rest  
         INTO postgresql://localhost/db?logs.apache  
          SET guc_1 = 'value', guc_2 = 'other value'  
 
 WHEN MATCHES rsyslog-msg IN others  
  REGISTERING timestamp, app-name, data  
         INTO postgresql://localhost/db?logs.others  
          SET guc_1 = 'value', guc_2 = 'other value'  
 
    WITH apache = rsyslog  
         DATA   = IP REST  
         IP     = 1*3DIGIT "." 1*3DIGIT "."1*3DIGIT "."1*3DIGIT  
         REST   = ~/.*/  
 
    WITH others = rsyslog; </code></pre><p>As the command is still experimental the options might be changed in the future and the details are not documented. </p><h2>AUTHOR</h2><p>Dimitri Fontaine <dimitri@2ndQuadrant.fr>  </p><h2>SEE ALSO</h2><p>PostgreSQL COPY documentation at <http://www.postgresql.org/docs/9.3/static/sql-copy.html> . </p><p>The pgloader source code and all documentation may be downloaded from <http://tapoueh.org/pgloader/> . </p>          </div>
        <div class="col-md-2"> </div>
        </div>

      <!-- FOOTER -->
      <footer>
        <p class="pull-right"><a href="#">Back to top</a></p>
        <p>&copy; 2013-2014 Dimitri Fontaine. &middot;</p>
      </footer>

    </div><!-- /.container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="../dist/js/bootstrap.min.js"></script>
    <!-- <script src="docs-assets/js/holder.js"></script> -->

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-47059482-2', 'tapoueh.org');
  ga('send', 'pageview');

</script>
  </body>
</html>