File: pgloader.1

package info (click to toggle)
pgloader 3.3.2%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,764 kB
  • ctags: 1,378
  • sloc: lisp: 11,210; makefile: 343; sh: 75; sql: 55
file content (3157 lines) | stat: -rw-r--r-- 97,054 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "PGLOADER" "1" "December 2016" "ff" ""
.
.SH "NAME"
\fBpgloader\fR \- PostgreSQL data loader
.
.SH "SYNOPSIS"
.
.nf

pgloader [<options>] [<command\-file>]\.\.\.
pgloader [<options>] SOURCE TARGET
.
.fi
.
.SH "DESCRIPTION"
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 \fBCOPY\fR PostgreSQL protocol to stream the data into the server, and manages errors by filling a pair of \fIreject\.dat\fR and \fIreject\.log\fR files\.
.
.P
pgloader operates either using commands which are read from files:
.
.IP "" 4
.
.nf

pgloader commands\.load
.
.fi
.
.IP "" 0
.
.P
or by using arguments and options all provided on the command line:
.
.IP "" 4
.
.nf

pgloader SOURCE TARGET
.
.fi
.
.IP "" 0
.
.SH "ARGUMENTS"
The pgloader arguments can be as many load files as needed, or a couple of connection strings to a specific input file\.
.
.SS "SOURCE CONNECTION STRING"
The source connection string format is as follows:
.
.IP "" 4
.
.nf

format:///absolute/path/to/file\.ext
format://\./relative/path/to/file\.ext
.
.fi
.
.IP "" 0
.
.P
Where format might be one of \fBcsv\fR, \fBfixed\fR, \fBcopy\fR, \fBdbf\fR, \fBdb3\fR or \fBixf\fR\.
.
.IP "" 4
.
.nf

db://user:pass@host:port/dbname
.
.fi
.
.IP "" 0
.
.P
Where db might be of \fBsqlite\fR, \fBmysql\fR or \fBmssql\fR\.
.
.P
When using a file based source format, pgloader also support natively fetching the file from an http location and decompressing an archive if needed\. In that case it\'s necessary to use the \fB\-\-type\fR option to specify the expected format of the file\. See the examples below\.
.
.P
Also note that some file formats require describing some implementation details such as columns to be read and delimiters and quoting when loading from csv\.
.
.P
For more complex loading scenarios, you will need to write a full fledge load command in the syntax described later in this document\.
.
.SS "TARGET CONNECTION STRING"
The target connection string format is described in details later in this document, see Section Connection String\.
.
.SH "OPTIONS"
.
.SS "INQUIRY OPTIONS"
Use these options when you want to know more about how to use \fBpgloader\fR, as those options will cause \fBpgloader\fR not to load any data\.
.
.TP
\fB\-h\fR, \fB\-\-help\fR
Show command usage summary and exit\.
.
.TP
\fB\-V\fR, \fB\-\-version\fR
Show pgloader version string and exit\.
.
.TP
\fB\-E\fR, \fB\-\-list\-encodings\fR
List known encodings in this version of pgloader\.
.
.TP
\fB\-U\fR, \fB\-\-upgrade\-config\fR
Parse given files in the command line as \fBpgloader\.conf\fR files with the \fBINI\fR syntax that was in use in pgloader versions 2\.x, and output the new command syntax for pgloader on standard output\.
.
.SS "GENERAL OPTIONS"
Those options are meant to tweak \fBpgloader\fR behavior when loading data\.
.
.IP "\(bu" 4
\fB\-v\fR, \fB\-\-verbose\fR: Be verbose\.
.
.IP "\(bu" 4
\fB\-q\fR, \fB\-\-quiet\fR: Be quiet\.
.
.IP "\(bu" 4
\fB\-d\fR, \fB\-\-debug\fR: Show debug level information messages\.
.
.IP "\(bu" 4
\fB\-D\fR, \fB\-\-root\-dir\fR: Set the root working directory (default to "/tmp/pgloader")\.
.
.IP "\(bu" 4
\fB\-L\fR, \fB\-\-logfile\fR: Set the pgloader log file (default to "/tmp/pgloader\.log")\.
.
.IP "\(bu" 4
\fB\-\-log\-min\-messages\fR: Minimum level of verbosity needed for log message to make it to the logfile\. One of critical, log, error, warning, notice, info or debug\.
.
.IP "\(bu" 4
\fB\-\-client\-min\-messages\fR: Minimum level of verbosity needed for log message to make it to the console\. One of critical, log, error, warning, notice, info or debug\.
.
.IP "\(bu" 4
\fB\-S\fR, \fB\-\-summary\fR: A filename where to copy the summary output\. When relative, the filename is expanded into \fB*root\-dir*\fR\.
.
.IP
The format of the filename defaults to being \fIhuman readable\fR\. It is possible to have the output in machine friendly formats such as \fICSV\fR, \fICOPY\fR (PostgreSQL\'s own COPY format) or \fIJSON\fR by specifying a filename with the extension resp\. \fB\.csv\fR, \fB\.copy\fR or \fB\.json\fR\.
.
.IP "\(bu" 4
\fB\-l <file>\fR, \fB\-\-load\-lisp\-file <file>\fR: Specify a lisp \fIfile\fR 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 \fBpgloader\.transforms\fR package\. This option can appear more than once in the command line\.
.
.IP "\(bu" 4
\fB\-\-dry\-run\fR:
.
.IP
Allow testing a \fB\.load\fR file without actually trying to load any data\. It\'s useful to debug it until it\'s ok, in particular to fix connection strings\.
.
.IP "\(bu" 4
\fB\-\-on\-error\-stop\fR
.
.IP
Alter pgloader behavior: rather than trying to be smart about error handling and continue loading good data, separating away the bad one, just stop as soon as PostgreSQL refuses anything sent to it\. Useful to debug data processing, transformation function and specific type casting\.
.
.IP "\(bu" 4
\fB\-\-self\-upgrade <directory>\fR:
.
.IP
Specify a \fIdirectory\fR 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\.
.
.IP "" 0
.
.SS "COMMAND LINE ONLY OPERATIONS"
Those options are meant to be used when using \fBpgloader\fR from the command line only, rather than using a command file and the rich command clauses and parser\. In simple cases, it can be much easier to use the \fISOURCE\fR and \fITARGET\fR directly on the command line, then tweak the loading with those options:
.
.IP "\(bu" 4
\fB\-\-with "option"\fR:
.
.IP
Allows setting options from the command line\. You can use that option as many times as you want\. The option arguments must follow the \fIWITH\fR clause for the source type of the \fBSOURCE\fR specification, as described later in this document\.
.
.IP "\(bu" 4
\fB\-\-set "guc_name=\'value\'"\fR
.
.IP
Allows setting PostgreSQL configuration from the command line\. Note that the option parsing is the same as when used from the \fISET\fR command clause, in particular you must enclose the guc value with single\-quotes\.
.
.IP "\(bu" 4
\fB\-\-field "\.\.\."\fR
.
.IP
Allows setting a source field definition\. Fields are accumulated in the order given on the command line\. It\'s possible to either use a \fB\-\-field\fR option per field in the source file, or to separate field definitions by a comma, as you would do in the \fIHAVING FIELDS\fR clause\.
.
.IP "\(bu" 4
\fB\-\-cast "\.\.\."\fR
.
.IP
Allows setting a specific casting rule for loading the data\.
.
.IP "\(bu" 4
\fB\-\-type csv|fixed|db3|ixf|sqlite|mysql|mssql\fR
.
.IP
Allows forcing the source type, in case when the \fISOURCE\fR parsing isn\'t satisfying\.
.
.IP "\(bu" 4
\fB\-\-encoding <encoding>\fR
.
.IP
Set the encoding of the source file to load data from\.
.
.IP "\(bu" 4
\fB\-\-before <filename>\fR
.
.IP
Parse given filename for SQL queries and run them against the target database before loading the data from the source\. The queries are parsed by pgloader itself: they need to be terminated by a semi\-colon (;) and the file may include \fB\ei\fR or \fB\eir\fR commands to \fIinclude\fR another file\.
.
.IP "\(bu" 4
\fB\-\-after <filename>\fR
.
.IP
Parse given filename for SQL queries and run them against the target database after having loaded the data from the source\. The queries are parsed in the same way as with the \fB\-\-before\fR option, see above\.
.
.IP "" 0
.
.SS "MORE DEBUG INFORMATION"
To get the maximum amount of debug information, you can use both the \fB\-\-verbose\fR and the \fB\-\-debug\fR switches at the same time, which is equivalent to saying \fB\-\-client\-min\-messages data\fR\. Then the log messages will show the data being processed, in the cases where the code has explicit support for it\.
.
.SH "USAGE EXAMPLES"
Review the command line options and pgloader\'s version:
.
.IP "" 4
.
.nf

pgloader \-\-help
pgloader \-\-version
.
.fi
.
.IP "" 0
.
.SS "Loading from a complex command"
Use the command file as the pgloader command argument, pgloader will parse that file and execute the commands found in it:
.
.IP "" 4
.
.nf

pgloader \-\-verbose \./test/csv\-districts\.load
.
.fi
.
.IP "" 0
.
.SS "CSV"
Load data from a CSV file into a pre\-existing table in your database:
.
.IP "" 4
.
.nf

pgloader \-\-type csv                                   \e
         \-\-field id \-\-field field                     \e
         \-\-with truncate                              \e
         \-\-with "fields terminated by \',\'"            \e
         \./test/data/matching\-1\.csv                   \e
         postgres:///pgloader?tablename=matching
.
.fi
.
.IP "" 0
.
.P
In that example the whole loading is driven from the command line, bypassing the need for writing a command in the pgloader command syntax entirely\. As there\'s no command though, the extra inforamtion needed must be provided on the command line using the \fB\-\-type\fR and \fB\-\-field\fR and \fB\-\-with\fR switches\.
.
.P
For documentation about the available syntaxes for the \fB\-\-field\fR and \fB\-\-with\fR switches, please refer to the CSV section later in the man page\.
.
.P
Note also that the PostgreSQL URI includes the target \fItablename\fR\.
.
.SS "Reading from STDIN"
File based pgloader sources can be loaded from the standard input, as in the following example:
.
.IP "" 4
.
.nf

pgloader \-\-type csv                                         \e
         \-\-field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong" \e
         \-\-with "skip header = 1"                          \e
         \-\-with "fields terminated by \'\et\'"                \e
         \-                                                 \e
         postgresql:///pgloader?districts_longlat          \e
         < test/data/2013_Gaz_113CDs_national\.txt
.
.fi
.
.IP "" 0
.
.P
The dash (\fB\-\fR) character as a source is used to mean \fIstandard input\fR, as usual in Unix command lines\. It\'s possible to stream compressed content to pgloader with this technique, using the Unix pipe:
.
.IP "" 4
.
.nf

gunzip \-c source\.gz | pgloader \-\-type csv \.\.\. \- pgsql:///target?foo
.
.fi
.
.IP "" 0
.
.SS "Loading from CSV available through HTTP"
The same command as just above can also be run if the CSV file happens to be found on a remote HTTP location:
.
.IP "" 4
.
.nf

pgloader \-\-type csv                                                     \e
         \-\-field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong" \e
         \-\-with "skip header = 1"                                       \e
         \-\-with "fields terminated by \'\et\'"                             \e
         http://pgsql\.tapoueh\.org/temp/2013_Gaz_113CDs_national\.txt     \e
         postgresql:///pgloader?districts_longlat
.
.fi
.
.IP "" 0
.
.P
Some more options have to be used in that case, as the file contains a one\-line header (most commonly that\'s column names, could be a copyright notice)\. Also, in that case, we specify all the fields right into a single \fB\-\-field\fR option argument\.
.
.P
Again, the PostgreSQL target connection string must contain the \fItablename\fR option and you have to ensure that the target table exists and may fit the data\. Here\'s the SQL command used in that example in case you want to try it yourself:
.
.IP "" 4
.
.nf

create table districts_longlat
(
         usps        text,
         geoid       text,
         aland       bigint,
         awater      bigint,
         aland_sqmi  double precision,
         awater_sqmi double precision,
         intptlat    double precision,
         intptlong   double precision
);
.
.fi
.
.IP "" 0
.
.P
Also notice that the same command will work against an archived version of the same data, e\.g\. http://pgsql\.tapoueh\.org/temp/2013_Gaz_113CDs_national\.txt\.gz\.
.
.P
Finally, it\'s important to note that pgloader first fetches the content from the HTTP URL it to a local file, then expand the archive when it\'s recognized to be one, and only then processes the locally expanded file\.
.
.P
In some cases, either because pgloader has no direct support for your archive format or maybe because expanding the archive is not feasible in your environment, you might want to \fIstream\fR the content straight from its remote location into PostgreSQL\. Here\'s how to do that, using the old battle tested Unix Pipes trick:
.
.IP "" 4
.
.nf

curl http://pgsql\.tapoueh\.org/temp/2013_Gaz_113CDs_national\.txt\.gz \e
| gunzip \-c                                                        \e
| pgloader \-\-type csv                                              \e
           \-\-field "usps,geoid,aland,awater,aland_sqmi,awater_sqmi,intptlat,intptlong"
           \-\-with "skip header = 1"                                \e
           \-\-with "fields terminated by \'\et\'"                      \e
           \-                                                       \e
           postgresql:///pgloader?districts_longlat
.
.fi
.
.IP "" 0
.
.P
Now the OS will take care of the streaming and buffering between the network and the commands and pgloader will take care of streaming the data down to PostgreSQL\.
.
.SS "Migrating from SQLite"
The following command will open the SQLite database, discover its tables definitions including indexes and foreign keys, migrate those definitions while \fIcasting\fR the data type specifications to their PostgreSQL equivalent and then migrate the data over:
.
.IP "" 4
.
.nf

createdb newdb
pgloader \./test/sqlite/sqlite\.db postgresql:///newdb
.
.fi
.
.IP "" 0
.
.SS "Migrating from MySQL"
Just create a database where to host the MySQL data and definitions and have pgloader do the migration for you in a single command line:
.
.IP "" 4
.
.nf

createdb pagila
pgloader mysql://user@localhost/sakila postgresql:///pagila
.
.fi
.
.IP "" 0
.
.SS "Fetching an archived DBF file from a HTTP remote location"
It\'s possible for pgloader to download a file from HTTP, unarchive it, and only then open it to discover the schema then load the data:
.
.IP "" 4
.
.nf

createdb foo
pgloader \-\-type dbf http://www\.insee\.fr/fr/methodes/nomenclatures/cog/telechargement/2013/dbf/historiq2013\.zip postgresql:///foo
.
.fi
.
.IP "" 0
.
.P
Here it\'s not possible for pgloader to guess the kind of data source it\'s being given, so it\'s necessary to use the \fB\-\-type\fR command line switch\.
.
.SH "BATCHES AND RETRY BEHAVIOUR"
To load data to PostgreSQL, pgloader uses the \fBCOPY\fR streaming protocol\. While this is the faster way to load data, \fBCOPY\fR 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
To work around that, pgloader cuts the data into \fIbatches\fR 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 \fBCOPY\fR streaming happens, in order to be able to handle errors should some happen\.
.
.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 \fICONTEXT\fR 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:
.
.IP "" 4
.
.nf

CONTEXT: COPY errors, line 3, column b: "2006\-13\-11"
.
.fi
.
.IP "" 0
.
.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
At the end of a load containing rejected rows, you will find two files in the \fIroot\-dir\fR location, under a directory named the same as the target database of your setup\. The filenames are the target table, and their extensions are \fB\.dat\fR for the rejected data and \fB\.log\fR for the file containing the full PostgreSQL client side logs about the rejected data\.
.
.P
The \fB\.dat\fR file is formatted in PostgreSQL the text COPY format as documented in http://www\.postgresql\.org/docs/9\.2/static/sql\-copy\.html#AEN66609 \fI\fR\.
.
.SH "A NOTE ABOUT PERFORMANCE"
pgloader has been developed with performance in mind, to be able to cope with ever growing needs in loading large amounts of data into PostgreSQL\.
.
.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 \fItransformations\fR to the input data and stream the end result to PostgreSQL using the COPY protocol\.
.
.P
When given a file that the PostgreSQL \fBCOPY\fR 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 \fBCOPY\fR command\.
.
.P
Note that while the \fBCOPY\fR 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 \fBpsql\fR implements a \fB\ecopy\fR 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\.
.
.SH "A NOTE ABOUT PARALLELISM"
pgloader uses several concurrent tasks to process the data being loaded:
.
.IP "\(bu" 4
a reader task reads the data in,
.
.IP "\(bu" 4
at least one transformer task is responsible for applying the needed transformations to given data so that it fits PostgreSQL expectations, those transformations include CSV like user\-defined \fIprojections\fR, database \fIcasting\fR (default and user given), and PostgreSQL specific \fIformatting\fR of the data for the COPY protocol and in unicode,
.
.IP "\(bu" 4
at least one writer task is responsible for sending the data down to PostgreSQL using the COPY protocol\.
.
.IP "" 0
.
.P
The idea behind having the transformer task do the \fIformatting\fR is so that in the event of bad rows being rejected by PostgreSQL the retry process doesn\'t have to do that step again\.
.
.P
At the moment, the number of transformer and writer tasks are forced into being the same, which allows for a very simple \fIqueueing\fR model to be implemented: the reader task fills in one queue per transformer task, which then pops from that queue and pushes to a writer queue per COPY task\.
.
.P
The parameter \fIworkers\fR allows to control how many worker threads are allowed to be active at any time (that\'s the parallelism level); and the parameter \fIconcurrency\fR allows to control how many tasks are started to handle the data (they may not all run at the same time, depending on the \fIworkers\fR setting)\.
.
.P
With a \fIconcurrency\fR of 2, we start 1 reader thread, 2 transformer threads and 2 writer tasks, that\'s 5 concurrent tasks to schedule into \fIworkers\fR threads\.
.
.P
So with \fBworkers = 4, concurrency = 2\fR, the parallel scheduler will maintain active only 4 of the 5 tasks that are started\.
.
.P
With \fBworkers = 8, concurrency = 1\fR, we then are able to work on several units of work at the same time\. In the database sources, a unit of work is a table, so those settings allow pgloader to be active on as many as 3 tables at any time in the load process\.
.
.P
The defaults are \fBworkers = 4, concurrency = 1\fR when loading from a database source, and \fBworkers = 8, concurrency = 2\fR when loading from something else (currently, a file)\. Those defaults are arbitrary and waiting for feedback from users, so please consider providing feedback if you play with the settings\.
.
.P
As the \fBCREATE INDEX\fR threads started by pgloader are only waiting until PostgreSQL is done with the real work, those threads are \fINOT\fR counted into the concurrency levels as detailed here\.
.
.P
By default, as many \fBCREATE INDEX\fR threads as the maximum number of indexes per table are found in your source schema\. It is possible to set the \fBmax parallel create index\fR \fIWITH\fR option to another number in case there\'s just too many of them to create\.
.
.SH "SOURCE FORMATS"
pgloader supports the following input formats:
.
.IP "\(bu" 4
csv, which includes also tsv and other common variants where you can change the \fIseparator\fR and the \fIquoting\fR rules and how to \fIescape\fR the \fIquotes\fR themselves;
.
.IP "\(bu" 4
fixed columns file, where pgloader is flexible enough to accomodate with source files missing columns (\fIragged fixed length column files\fR do exist);
.
.IP "\(bu" 4
PostgreSLQ COPY formatted files, following the COPY TEXT documentation of PostgreSQL, such as the reject files prepared by pgloader;
.
.IP "\(bu" 4
dbase files known as db3 or dbf file;
.
.IP "\(bu" 4
ixf formated files, ixf being a binary storage format from IBM;
.
.IP "\(bu" 4
sqlite databases with fully automated discovery of the schema and advanced cast rules;
.
.IP "\(bu" 4
mysql databases with fully automated discovery of the schema and advanced cast rules;
.
.IP "\(bu" 4
MS SQL databases with fully automated discovery of the schema and advanced cast rules\.
.
.IP "" 0
.
.SH "PGLOADER COMMANDS SYNTAX"
pgloader implements a Domain Specific Language allowing to setup complex data loading scripts handling computed columns and on\-the\-fly sanitization of the input data\. For more complex data loading scenarios, you will be required to learn that DSL\'s syntax\. It\'s meant to look familiar to DBA by being inspired by SQL where it makes sense, which is not that much after all\.
.
.P
The pgloader commands follow the same global grammar rules\. Each of them might support only a subset of the general options and provide specific options\.
.
.IP "" 4
.
.nf

LOAD <source\-type>
     FROM <source\-url>     [ HAVING FIELDS <source\-level\-options> ]
     INTO <postgresql\-url> [ TARGET COLUMNS <columns\-and\-options> ]

[ WITH <load\-options> ]

[ SET <postgresql\-settings> ]

[ BEFORE LOAD [ DO <sql statements> | EXECUTE <sql file> ] \.\.\. ]
[  AFTER LOAD [ DO <sql statements> | EXECUTE <sql file> ] \.\.\. ]
;
.
.fi
.
.IP "" 0
.
.P
The main clauses are the \fBLOAD\fR, \fBFROM\fR, \fBINTO\fR and \fBWITH\fR clauses that each command implements\. Some command then implement the \fBSET\fR command, or some specific clauses such as the \fBCAST\fR clause\.
.
.SH "COMMON CLAUSES"
Some clauses are common to all commands:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
The \fIFROM\fR clause specifies where to read the data from, and each command introduces its own variant of sources\. For instance, the \fICSV\fR source supports \fBinline\fR, \fBstdin\fR, a filename, a quoted filename, and a \fIFILENAME MATCHING\fR clause (see above); whereas the \fIMySQL\fR source only supports a MySQL database URI specification\.
.
.IP
In all cases, the \fIFROM\fR clause is able to read its value from an environment variable when using the form \fBGETENV \'varname\'\fR\.
.
.IP "\(bu" 4
\fIINTO\fR
.
.IP
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\.
.
.IP
The \fIINTO\fR target database connection URI can be parsed from the value of an environment variable when using the form \fBGETENV \'varname\'\fR\.
.
.IP
Then \fIINTO\fR option also supports an optional comma separated list of target columns, which are either the name of an input \fIfield\fR or the white space separated list of the target column name, its PostgreSQL data type and a \fIUSING\fR expression\.
.
.IP
The \fIUSING\fR expression can be any valid Common Lisp form and will be read with the current package set to \fBpgloader\.transforms\fR, so that you can use functions defined in that package, such as functions loaded dynamically with the \fB\-\-load\fR command line parameter\.
.
.IP
Each \fIUSING\fR expression is compiled at runtime to native code\.
.
.IP
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\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
Set of options to apply to the command, using a global syntax of either:
.
.IP "\(bu" 4
\fIkey = value\fR
.
.IP "\(bu" 4
\fIuse option\fR
.
.IP "\(bu" 4
\fIdo not use option\fR
.
.IP "" 0
.
.IP
See each specific command for details\.
.
.IP
All data sources specific commands support the following options:
.
.IP "\(bu" 4
\fIbatch rows = R\fR
.
.IP "\(bu" 4
\fIbatch size = \.\.\. MB\fR
.
.IP "\(bu" 4
\fIbatch concurrency = \.\.\.\fR
.
.IP "" 0
.
.IP
See the section BATCH BEHAVIOUR OPTIONS for more details\.
.
.IP
In addition, the following settings are available:
.
.IP "\(bu" 4
\fIworkers = W\fR
.
.IP "\(bu" 4
\fIconcurrency = C\fR
.
.IP "\(bu" 4
\fImax parallel create index = I\fR
.
.IP "" 0
.
.IP
See section A NOTE ABOUT PARALLELISM for more details\.
.
.IP "\(bu" 4
\fISET\fR
.
.IP
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\.
.
.IP
The names and values of the parameters are not validated by pgloader, they are given as\-is to PostgreSQL\.
.
.IP "\(bu" 4
\fIBEFORE LOAD DO\fR
.
.IP
You can run SQL queries against the database before loading the data from the \fBCSV\fR file\. Most common SQL queries are \fBCREATE TABLE IF NOT EXISTS\fR so that the data can be loaded\.
.
.IP
Each command must be \fIdollar\-quoted\fR: it must begin and end with a double dollar sign, \fB$$\fR\. Dollar\-quoted queries are then comma separated\. No extra punctuation is expected after the last SQL query\.
.
.IP "\(bu" 4
\fIBEFORE LOAD EXECUTE\fR
.
.IP
Same behaviour as in the \fIBEFORE LOAD DO\fR clause\. Allows you to read the SQL queries from a SQL file\. Implements support for PostgreSQL dollar\-quoting and the \fB\ei\fR and \fB\eir\fR include facilities as in \fBpsql\fR batch mode (where they are the same thing)\.
.
.IP "\(bu" 4
\fIAFTER LOAD DO\fR
.
.IP
Same format as \fIBEFORE LOAD DO\fR, 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\.
.
.IP "\(bu" 4
\fIAFTER LOAD EXECUTE\fR
.
.IP
Same behaviour as in the \fIAFTER LOAD DO\fR clause\. Allows you to read the SQL queries from a SQL file\. Implements support for PostgreSQL dollar\-quoting and the \fB\ei\fR and \fB\eir\fR include facilities as in \fBpsql\fR batch mode (where they are the same thing)\.
.
.IP "" 0
.
.SS "Connection String"
The \fB<postgresql\-url>\fR parameter is expected to be given as a \fIConnection URI\fR as documented in the PostgreSQL documentation at http://www\.postgresql\.org/docs/9\.3/static/libpq\-connect\.html#LIBPQ\-CONNSTRING\.
.
.IP "" 4
.
.nf

postgresql://[user[:password]@][netloc][:port][/dbname][?option=value&\.\.\.]
.
.fi
.
.IP "" 0
.
.P
Where:
.
.IP "\(bu" 4
\fIuser\fR
.
.IP
Can contain any character, including colon (\fB:\fR) which must then be doubled (\fB::\fR) and at\-sign (\fB@\fR) which must then be doubled (\fB@@\fR)\.
.
.IP
When omitted, the \fIuser\fR name defaults to the value of the \fBPGUSER\fR environment variable, and if it is unset, the value of the \fBUSER\fR environment variable\.
.
.IP "\(bu" 4
\fIpassword\fR
.
.IP
Can contain any character, including the at sign (\fB@\fR) which must then be doubled (\fB@@\fR)\. To leave the password empty, when the \fIuser\fR name ends with at at sign, you then have to use the syntax user:@\.
.
.IP
When omitted, the \fIpassword\fR defaults to the value of the \fBPGPASSWORD\fR environment variable if it is set, otherwise the password is left unset\.
.
.IP "\(bu" 4
\fInetloc\fR
.
.IP
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 \fIunix domain socket\fR that method is preferred, otherwise the \fInetloc\fR default to \fBlocalhost\fR\.
.
.IP
It\'s possible to force the \fIunix domain socket\fR path by using the syntax \fBunix:/path/to/where/the/socket/file/is\fR, so to force a non default socket path and a non default port, you would have:
.
.IP "" 4
.
.nf

postgresql://unix:/tmp:54321/dbname
.
.fi
.
.IP "" 0
.
.IP
The \fInetloc\fR defaults to the value of the \fBPGHOST\fR environment variable, and if it is unset, to either the default \fBunix\fR socket path when running on a Unix system, and \fBlocalhost\fR otherwise\.
.
.IP "\(bu" 4
\fIdbname\fR
.
.IP
Should be a proper identifier (letter followed by a mix of letters, digits and the punctuation signs comma (\fB,\fR), dash (\fB\-\fR) and underscore (\fB_\fR)\.
.
.IP
When omitted, the \fIdbname\fR defaults to the value of the environment variable \fBPGDATABASE\fR, and if that is unset, to the \fIuser\fR value as determined above\.
.
.IP "\(bu" 4
\fIoptions\fR
.
.IP
The optional parameters must be supplied with the form \fBname=value\fR, and you may use several parameters by separating them away using an ampersand (\fB&\fR) character\.
.
.IP
Only some options are supported here, \fItablename\fR (which might be qualified with a schema name) \fIsslmode\fR, \fIhost\fR, \fIport\fR, \fIdbname\fR, \fIuser\fR and \fIpassword\fR\.
.
.IP
The \fIsslmode\fR parameter values can be one of \fBdisable\fR, \fBallow\fR, \fBprefer\fR or \fBrequire\fR\.
.
.IP
For backward compatibility reasons, it\'s possible to specify the \fItablename\fR option directly, without spelling out the \fBtablename=\fR parts\.
.
.IP
The options override the main URI components when both are given, and using the percent\-encoded option parameters allow using passwords starting with a colon and bypassing other URI components parsing limitations\.
.
.IP "" 0
.
.SS "Regular Expressions"
Several clauses listed in the following accept \fIregular expressions\fR with the following input rules:
.
.IP "\(bu" 4
A regular expression begins with a tilde sign (\fB~\fR),
.
.IP "\(bu" 4
is then followed with an opening sign,
.
.IP "\(bu" 4
then any character is allowed and considered part of the regular expression, except for the closing sign,
.
.IP "\(bu" 4
then a closing sign is expected\.
.
.IP "" 0
.
.P
The opening and closing sign are allowed by pair, here\'s the complete list of allowed delimiters:
.
.IP "" 4
.
.nf

~//
~[]
~{}
~()
~<>
~""
~\'\'
~||
~##
.
.fi
.
.IP "" 0
.
.P
Pick the set of delimiters that don\'t collide with the \fIregular expression\fR 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\.
.
.SS "Comments"
Any command may contain comments, following those input rules:
.
.IP "\(bu" 4
the \fB\-\-\fR delimiter begins a comment that ends with the end of the current line,
.
.IP "\(bu" 4
the delimiters \fB/*\fR and \fB*/\fR respectively start and end a comment, which can be found in the middle of a command or span several lines\.
.
.IP "" 0
.
.P
Any place where you could enter a \fIwhitespace\fR will accept a comment too\.
.
.SS "Batch behaviour options"
All pgloader commands have support for a \fIWITH\fR clause that allows for specifying options\. Some options are generic and accepted by all commands, such as the \fIbatch behaviour options\fR, and some options are specific to a data source kind, such as the CSV \fIskip header\fR option\.
.
.P
The global batch behaviour options are:
.
.IP "\(bu" 4
\fIbatch rows\fR
.
.IP
Takes a numeric value as argument, used as the maximum number of rows allowed in a batch\. The default is \fB25 000\fR and can be changed to try having better performance characteristics or to control pgloader memory usage;
.
.IP "\(bu" 4
\fIbatch size\fR
.
.IP
Takes a memory unit as argument, such as \fI20 MB\fR, its default value\. Accepted multipliers are \fIkB\fR, \fIMB\fR, \fIGB\fR, \fITB\fR and \fIPB\fR\. The case is important so as not to be confused about bits versus bytes, we\'re only talking bytes here\.
.
.IP "\(bu" 4
\fIbatch concurrency\fR
.
.IP
Takes a numeric value as argument, defaults to \fB10\fR\. That\'s the number of batches that pgloader is allows to build in memory in each reader thread\. See the \fIworkers\fR setting for how many reader threads are allowed to run at the same time: each of them is allowed as many as \fIbatch concurrency\fR batches\.
.
.IP "" 0
.
.P
Other options are specific to each input source, please refer to specific parts of the documentation for their listing and covering\.
.
.P
A batch is then closed as soon as either the \fIbatch rows\fR or the \fIbatch size\fR threshold is crossed, whichever comes first\. In cases when a batch has to be closed because of the \fIbatch size\fR setting, a \fIdebug\fR level log message is printed with how many rows did fit in the \fIoversized\fR batch\.
.
.SH "LOAD CSV"
This command instructs pgloader to load data from a \fBCSV\fR file\. Here\'s an example:
.
.IP "" 4
.
.nf

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 \'\et\'

    SET work_mem to \'32 MB\', maintenance_work_mem to \'64 MB\';
.
.fi
.
.IP "" 0
.
.P
The \fBcsv\fR format command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Filename where to load the data from\. Accepts an \fIENCODING\fR option\. Use the \fB\-\-list\-encodings\fR option to know which encoding names are supported\.
.
.IP
The filename may be enclosed by single quotes, and could be one of the following special values:
.
.IP "\(bu" 4
\fIinline\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIstdin\fR
.
.IP
Reads the data from the standard input stream\.
.
.IP "\(bu" 4
\fIFILENAMES MATCHING\fR
.
.IP
The whole \fImatching\fR clause must follow the following rule:
.
.IP "" 4
.
.nf

[ ALL FILENAMES | [ FIRST ] FILENAME ]
MATCHING regexp
[ IN DIRECTORY \'\.\.\.\' ]
.
.fi
.
.IP "" 0
.
.IP
The \fImatching\fR clause applies given \fIregular expression\fR (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\.
.
.IP
The optional \fIIN DIRECTORY\fR 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\.
.
.IP "" 0
.
.IP
The \fIFROM\fR option also supports an optional comma separated list of \fIfield\fR names describing what is expected in the \fBCSV\fR data file, optionally introduced by the clause \fBHAVING FIELDS\fR\.
.
.IP
Each field name can be either only one name or a name following with specific reader options for that field, enclosed in square brackets and comma\-separated\. Supported per\-field reader options are:
.
.IP "\(bu" 4
\fIterminated by\fR
.
.IP
See the description of \fIfield terminated by\fR below\.
.
.IP
The processing of this option is not currently implemented\.
.
.IP "\(bu" 4
\fIdate format\fR
.
.IP
When the field is expected of the date type, then this option allows to specify the date format used in the file\.
.
.IP
Date format string are template strings modeled against the PostgreSQL \fBto_char\fR template strings support, limited to the following patterns:
.
.IP "\(bu" 4
YYYY, YYY, YY for the year part
.
.IP "\(bu" 4
MM for the numeric month part
.
.IP "\(bu" 4
DD for the numeric day part
.
.IP "\(bu" 4
HH, HH12, HH24 for the hour part
.
.IP "\(bu" 4
am, AM, a\.m\., A\.M\.
.
.IP "\(bu" 4
pm, PM, p\.m\., P\.M\.
.
.IP "\(bu" 4
MI for the minutes part
.
.IP "\(bu" 4
SS for the seconds part
.
.IP "\(bu" 4
MS for the milliseconds part (4 digits)
.
.IP "\(bu" 4
US for the microseconds part (6 digits)
.
.IP "\(bu" 4
unparsed punctuation signs: \- \. * # @ T / \e and space
.
.IP "" 0
.
.IP
Here\'s an example of a \fIdate format\fR specification:
.
.IP "" 4
.
.nf

column\-name [date format \'YYYY\-MM\-DD HH24\-MI\-SS\.US\']
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fInull if\fR
.
.IP
This option takes an argument which is either the keyword \fIblanks\fR or a double\-quoted string\.
.
.IP
When \fIblanks\fR is used and the field value that is read contains only space characters, then it\'s automatically converted to an SQL \fBNULL\fR value\.
.
.IP
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 \fBNULL\fR value\.
.
.IP "\(bu" 4
\fItrim both whitespace\fR, \fItrim left whitespace\fR, \fItrim right whitespace\fR
.
.IP
This option allows to trim whitespaces in the read data, either from both sides of the data, or only the whitespace characters found on the left of the streaing, or only those on the right of the string\.
.
.IP "" 0

.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBCSV\fR file, the following options are supported:
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issues a \fBTRUNCATE\fR command against the PostgreSQL target table before reading the data file\.
.
.IP "\(bu" 4
\fIdrop indexes\fR
.
.IP
When this option is listed, pgloader issues \fBDROP INDEX\fR commands against all the indexes defined on the target table before copying the data, then \fBCREATE INDEX\fR commands once the \fBCOPY\fR is done\.
.
.IP
In order to get the best performance possible, all the indexes are created in parallel and when done the primary keys are built again from the unique indexes just created\. This two step process allows creating the primary key index in parallel with the other indexes, as only the \fBALTER TABLE\fR command needs an \fIaccess exclusive lock\fR on the target table\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIskip header\fR
.
.IP
Takes a numeric value as argument\. Instruct pgloader to skip that many lines at the beginning of the input file\.
.
.IP "\(bu" 4
\fIcsv header\fR
.
.IP
Use the first line read after \fIskip header\fR as the list of csv field names to be found in the CSV file, using the same CSV parameters as for the CSV data\.
.
.IP "\(bu" 4
\fItrim unquoted blanks\fR
.
.IP
When reading unquoted values in the \fBCSV\fR file, remove the blanks found in between the separator and the value\. That behaviour is the default\.
.
.IP "\(bu" 4
\fIkeep unquoted blanks\fR
.
.IP
When reading unquoted values in the \fBCSV\fR file, keep blanks found in between the separator and the value\.
.
.IP "\(bu" 4
\fIfields optionally enclosed by\fR
.
.IP
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 \et to denote a tabulation character, or \fB0x\fR then an hexadecimal value read as the ASCII code for the character\.
.
.IP
This character is used as the quoting character in the \fBCSV\fR file, and defaults to double\-quote\.
.
.IP "\(bu" 4
\fIfields not enclosed\fR
.
.IP
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 \fIfields not enclosed\fR for the CSV parser to accept those values\.
.
.IP "\(bu" 4
\fIfields escaped by\fR
.
.IP
Takes either the special value \fIbackslash\-quote\fR or \fIdouble\-quote\fR, or any value supported by the \fIfields terminated by\fR option (see below)\. This value is used to recognize escaped field separators when they are to be found within the data fields themselves\. Defaults to \fIdouble\-quote\fR\.
.
.IP "\(bu" 4
\fIcsv escape mode\fR
.
.IP
Takes either the special value \fIquote\fR (the default) or \fIfollowing\fR and allows the CSV parser to parse either only escaped field separator or any character (including CSV data) when using the \fIfollowing\fR value\.
.
.IP "\(bu" 4
\fIfields terminated by\fR
.
.IP
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 \et to denote a tabulation character, or \fB0x\fR then an hexadecimal value read as the ASCII code for the character\.
.
.IP
This character is used as the \fIfield separator\fR when reading the \fBCSV\fR data\.
.
.IP "\(bu" 4
\fIlines terminated by\fR
.
.IP
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 \et to denote a tabulation character, or \fB0x\fR then an hexadecimal value read as the ASCII code for the character\.
.
.IP
This character is used to recognize \fIend\-of\-line\fR condition when reading the \fBCSV\fR data\.
.
.IP "" 0

.
.IP "" 0
.
.SH "LOAD FIXED COLS"
This command instructs pgloader to load data from a text file containing columns arranged in a \fIfixed size\fR manner\. Here\'s an example:
.
.IP "" 4
.
.nf

LOAD FIXED
     FROM inline
          (
           a from  0 for 10,
           b from 10 for  8,
           c from 18 for  8,
           d from 26 for 17 [null if blanks, trim right whitespace]
          )
     INTO postgresql:///pgloader?fixed
          (
             a, b,
             c time using (time\-with\-no\-separator c),
             d
          )

     WITH truncate

      SET 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
  2345609872014092914371500
  2345678902014092914371520
.
.fi
.
.IP "" 0
.
.P
The \fBfixed\fR format command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Filename where to load the data from\. Accepts an \fIENCODING\fR option\. Use the \fB\-\-list\-encodings\fR option to know which encoding names are supported\.
.
.IP
The filename may be enclosed by single quotes, and could be one of the following special values:
.
.IP "\(bu" 4
\fIinline\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIstdin\fR
.
.IP
Reads the data from the standard input stream\.
.
.IP "\(bu" 4
\fIFILENAMES MATCHING\fR
.
.IP
The whole \fImatching\fR clause must follow the following rule:
.
.IP "" 4
.
.nf

[ ALL FILENAMES | [ FIRST ] FILENAME ]
MATCHING regexp
[ IN DIRECTORY \'\.\.\.\' ]
.
.fi
.
.IP "" 0
.
.IP
The \fImatching\fR clause applies given \fIregular expression\fR (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\.
.
.IP
The optional \fIIN DIRECTORY\fR 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\.
.
.IP "" 0
.
.IP
The \fIFROM\fR option also supports an optional comma separated list of \fIfield\fR names describing what is expected in the \fBFIXED\fR data file\.
.
.IP
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 \fIstart\fR and \fIlength\fR are required\.
.
.IP "\(bu" 4
\fIstart\fR
.
.IP
Position in the line where to start reading that field\'s value\. Can be entered with decimal digits or \fB0x\fR then hexadecimal digits\.
.
.IP "\(bu" 4
\fIlength\fR
.
.IP
How many bytes to read from the \fIstart\fR position to read that field\'s value\. Same format as \fIstart\fR\.
.
.IP "" 0
.
.IP
Those optional parameters must be enclosed in square brackets and comma\-separated:
.
.IP "\(bu" 4
\fIterminated by\fR
.
.IP
See the description of \fIfield terminated by\fR below\.
.
.IP
The processing of this option is not currently implemented\.
.
.IP "\(bu" 4
\fIdate format\fR
.
.IP
When the field is expected of the date type, then this option allows to specify the date format used in the file\.
.
.IP
Date format string are template strings modeled against the PostgreSQL \fBto_char\fR template strings support, limited to the following patterns:
.
.IP "\(bu" 4
YYYY, YYY, YY for the year part
.
.IP "\(bu" 4
MM for the numeric month part
.
.IP "\(bu" 4
DD for the numeric day part
.
.IP "\(bu" 4
HH, HH12, HH24 for the hour part
.
.IP "\(bu" 4
am, AM, a\.m\., A\.M\.
.
.IP "\(bu" 4
pm, PM, p\.m\., P\.M\.
.
.IP "\(bu" 4
MI for the minutes part
.
.IP "\(bu" 4
SS for the seconds part
.
.IP "\(bu" 4
MS for the milliseconds part (4 digits)
.
.IP "\(bu" 4
US for the microseconds part (6 digits)
.
.IP "\(bu" 4
unparsed punctuation signs: \- \. * # @ T / \e and space
.
.IP "" 0
.
.IP
Here\'s an example of a \fIdate format\fR specification:
.
.IP "" 4
.
.nf

column\-name [date format \'YYYY\-MM\-DD HH24\-MI\-SS\.US\']
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fInull if\fR
.
.IP
This option takes an argument which is either the keyword \fIblanks\fR or a double\-quoted string\.
.
.IP
When \fIblanks\fR is used and the field value that is read contains only space characters, then it\'s automatically converted to an SQL \fBNULL\fR value\.
.
.IP
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 \fBNULL\fR value\.
.
.IP "\(bu" 4
\fItrim both whitespace\fR, \fItrim left whitespace\fR, \fItrim right whitespace\fR
.
.IP
This option allows to trim whitespaces in the read data, either from both sides of the data, or only the whitespace characters found on the left of the streaing, or only those on the right of the string\.
.
.IP "" 0

.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBFIXED\fR file, the following options are supported:
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issues a \fBTRUNCATE\fR command against the PostgreSQL target table before reading the data file\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIskip header\fR
.
.IP
Takes a numeric value as argument\. Instruct pgloader to skip that many lines at the beginning of the input file\.
.
.IP "" 0

.
.IP "" 0
.
.SH "LOAD COPY FORMATTED FILES"
This commands instructs pgloader to load from a file containing COPY TEXT data as described in the PostgreSQL documentation\. Here\'s an example:
.
.IP "" 4
.
.nf

LOAD COPY
     FROM copy://\./data/track\.copy
          (
            trackid, track, album, media, genre, composer,
            milliseconds, bytes, unitprice
          )
     INTO postgresql:///pgloader?track_full

     WITH truncate

      SET work_mem to \'14MB\',
          standard_conforming_strings to \'on\'

BEFORE LOAD DO
     $$ drop table if exists track_full; $$,
     $$ create table track_full (
          trackid      bigserial,
          track        text,
          album        text,
          media        text,
          genre        text,
          composer     text,
          milliseconds bigint,
          bytes        bigint,
          unitprice    numeric
        );
     $$;
.
.fi
.
.IP "" 0
.
.P
The \fBCOPY\fR format command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIinline\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIstdin\fR
.
.IP
Reads the data from the standard input stream\.
.
.IP "\(bu" 4
\fIFILENAMES MATCHING\fR
.
.IP
The whole \fImatching\fR clause must follow the following rule:
.
.IP "" 4
.
.nf

[ ALL FILENAMES | [ FIRST ] FILENAME ]
MATCHING regexp
[ IN DIRECTORY \'\.\.\.\' ]
.
.fi
.
.IP "" 0
.
.IP
The \fImatching\fR clause applies given \fIregular expression\fR (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\.
.
.IP
The optional \fIIN DIRECTORY\fR 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\.
.
.IP "" 0

.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBCOPY\fR file, the following options are supported:
.
.IP "\(bu" 4
\fIdelimiter\fR
.
.IP
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 \et to denote a tabulation character, or \fB0x\fR then an hexadecimal value read as the ASCII code for the character\.
.
.IP
This character is used as the \fIdelimiter\fR when reading the data, in a similar way to the PostgreSQL \fBCOPY\fR option\.
.
.IP "\(bu" 4
\fInull\fR
.
.IP
Takes a quoted string as an argument (quotes can be either double quotes or single quotes) and uses that string as the \fBNULL\fR representation in the data\.
.
.IP
This is similar to the \fInull\fR \fBCOPY\fR option in PostgreSQL\.
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issues a \fBTRUNCATE\fR command against the PostgreSQL target table before reading the data file\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIskip header\fR
.
.IP
Takes a numeric value as argument\. Instruct pgloader to skip that many lines at the beginning of the input file\.
.
.IP "" 0

.
.IP "" 0
.
.SH "LOAD DBF"
This command instructs pgloader to load data from a \fBDBF\fR file\. Here\'s an example:
.
.IP "" 4
.
.nf

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;
.
.fi
.
.IP "" 0
.
.P
The \fBdbf\fR format command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBDBF\fR file, the following options are supported:
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issues a \fBTRUNCATE\fR command against the PostgreSQL target table before reading the data file\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIcreate table\fR
.
.IP
When this option is listed, pgloader creates the table using the meta data found in the \fBDBF\fR file, which must contain a list of fields with their data type\. A standard data type conversion from DBF to PostgreSQL is done\.
.
.IP "\(bu" 4
\fItable name\fR
.
.IP
This options expects as its value the possibly qualified name of the table to create\.
.
.IP "" 0

.
.IP "" 0
.
.SH "LOAD IXF"
This command instructs pgloader to load data from an IBM \fBIXF\fR file\. Here\'s an example:
.
.IP "" 4
.
.nf

LOAD IXF
    FROM data/nsitra\.test1\.ixf
    INTO postgresql:///pgloader?nsitra\.test1
    WITH truncate, create table, timezone UTC

  BEFORE LOAD DO
   $$ create schema if not exists nsitra; $$,
   $$ drop table if exists nsitra\.test1; $$;
.
.fi
.
.IP "" 0
.
.P
The \fBixf\fR format command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBIXF\fR file, the following options are supported:
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issues a \fBTRUNCATE\fR command against the PostgreSQL target table before reading the data file\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIcreate table\fR
.
.IP
When this option is listed, pgloader creates the table using the meta data found in the \fBDBF\fR file, which must contain a list of fields with their data type\. A standard data type conversion from DBF to PostgreSQL is done\.
.
.IP "\(bu" 4
\fItable name\fR
.
.IP
This options expects as its value the possibly qualified name of the table to create\.
.
.IP "\(bu" 4
\fItimezone\fR
.
.IP
This options allows to specify which timezone is used when parsing timestamps from an IXF file, and defaults to \fIUTC\fR\. Expected values are either \fBUTC\fR, \fBGMT\fR or a single quoted location name such as \fB\'Universal\'\fR or \fB\'Europe/Paris\'\fR\.
.
.IP "" 0

.
.IP "" 0
.
.SH "LOAD ARCHIVE"
This command instructs pgloader to load data from one or more files contained in an archive\. Currently the only supported archive format is \fIZIP\fR, and the archive might be downloaded from an \fIHTTP\fR URL\.
.
.P
Here\'s an example:
.
.IP "" 4
.
.nf

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; $$,

     EXECUTE \'geolite\.sql\'

   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); $$;
.
.fi
.
.IP "" 0
.
.P
The \fBarchive\fR command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Filename or HTTP URI where to load the data from\. When given an HTTP URL the linked file will get downloaded locally before processing\.
.
.IP
If the file is a \fBzip\fR file, the command line utility \fBunzip\fR is used to expand the archive into files in \fB$TMPDIR\fR, or \fB/tmp\fR if \fB$TMPDIR\fR is unset or set to a non\-existing directory\.
.
.IP
Then the following commands are used from the top level directory where the archive has been expanded\.
.
.IP "\(bu" 4
command [ \fIAND\fR command \.\.\. ]
.
.IP
A series of commands against the contents of the archive, at the moment only \fBCSV\fR,\fB\'FIXED\fR and \fBDBF\fR commands are supported\.
.
.IP
Note that commands are supporting the clause \fIFROM FILENAME MATCHING\fR which allows the pgloader command not to depend on the exact names of the archive directories\.
.
.IP
The same clause can also be applied to several files with using the spelling \fIFROM ALL FILENAMES MATCHING\fR and a regular expression\.
.
.IP
The whole \fImatching\fR clause must follow the following rule:
.
.IP "" 4
.
.nf

 FROM [ ALL FILENAMES | [ FIRST ] FILENAME ] MATCHING
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIFINALLY DO\fR
.
.IP
SQL Queries to run once the data is loaded, such as \fBCREATE INDEX\fR\.
.
.IP "" 0
.
.SH "LOAD MYSQL DATABASE"
This command instructs pgloader to load data from a database connection\. The only supported database source is currently \fIMySQL\fR, and pgloader supports dynamically converting the schema of the source database and the indexes building\.
.
.P
A default set of casting rules are provided and might be overloaded and appended to by the command\.
.
.P
Here\'s an example:
.
.IP "" 4
.
.nf

LOAD DATABASE
     FROM      mysql://root@localhost/sakila
     INTO postgresql://localhost:54393/sakila

 WITH include drop, create tables, create indexes, reset sequences,
      workers = 8, concurrency = 1

  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 ~<ory>
 \-\- DECODING TABLE NAMES MATCHING ~/messed/, ~/encoding/ AS utf8
 \-\- ALTER TABLE NAMES MATCHING \'film\' RENAME TO \'films\'
 \-\- ALTER TABLE NAMES MATCHING ~/_list$/ SET SCHEMA \'mv\'

 BEFORE LOAD DO
 $$ create schema if not exists sakila; $$;
.
.fi
.
.IP "" 0
.
.P
The \fBdatabase\fR command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Must be a connection URL pointing to a MySQL database\.
.
.IP
If the connection URI contains a table name, then only this table is migrated from MySQL to PostgreSQL\.
.
.IP
See the \fBSOURCE CONNECTION STRING\fR section above for details on how to write the connection string\. Environment variables described in \fIhttp://dev\.mysql\.com/doc/refman/5\.0/en/environment\-variables\.html\fR can be used as default values too\. If the user is not provided, then it defaults to \fBUSER\fR environment variable value\. The password can be provided with the environment variable \fBMYSQL_PWD\fR\. The host can be provided with the environment variable \fBMYSQL_HOST\fR and otherwise defaults to \fBlocalhost\fR\. The port can be provided with the environment variable \fBMYSQL_TCP_PORT\fR and otherwise defaults to \fB3306\fR\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBMySQL\fR database, the following options are supported, and the efault \fIWITH\fR clause is: \fIno truncate\fR, \fIcreate tables\fR, \fIinclude drop\fR, \fIcreate indexes\fR, \fIreset sequences\fR, \fIforeign keys\fR, \fIdowncase identifiers\fR\.
.
.IP
\fIWITH\fR options:
.
.IP "\(bu" 4
\fIinclude drop\fR
.
.IP
When this option is listed, pgloader drops all the tables in the target PostgreSQL database whose names appear 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\. Please note that \fBCASCADE\fR is used to ensure that tables are dropped even if there are foreign keys pointing to them\. This is precisely what \fBinclude drop\fR is intended to do: drop all target tables and recreate them\.
.
.IP
Great care needs to be taken when using \fBinclude drop\fR, as it will cascade to \fIall\fR objects referencing the target tables, possibly including other tables that are not being loaded from the source DB\.
.
.IP "\(bu" 4
\fIinclude no drop\fR
.
.IP
When this option is listed, pgloader will not include any \fBDROP\fR statement when loading the data\.
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issue the \fBTRUNCATE\fR command against each PostgreSQL table just before loading data into it\.
.
.IP "\(bu" 4
\fIno truncate\fR
.
.IP
When this option is listed, pgloader issues no \fBTRUNCATE\fR command\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIcreate tables\fR
.
.IP
When this option is listed, pgloader creates the table using the meta data found in the \fBMySQL\fR file, which must contain a list of fields with their data type\. A standard data type conversion from DBF to PostgreSQL is done\.
.
.IP "\(bu" 4
\fIcreate no tables\fR
.
.IP
When this option is listed, pgloader skips the creation of table before loading data, target tables must then already exist\.
.
.IP
Also, when using \fIcreate no tables\fR pgloader fetches the metadata from the current target database and checks type casting, then will remove constraints and indexes prior to loading the data and install them back again once the loading is done\.
.
.IP "\(bu" 4
\fIcreate indexes\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIcreate no indexes\fR
.
.IP
When this option is listed, pgloader skips the creating indexes\.
.
.IP "\(bu" 4
\fIuniquify index names\fR, \fIpreserve index names\fR
.
.IP
MySQL index names are unique per\-table whereas in PostgreSQL index names have to be unique per\-schema\. The default for pgloader is to change the index name by prefixing it with \fBidx_OID\fR where \fBOID\fR is the internal numeric identifier of the table the index is built against\.
.
.IP
In somes cases like when the DDL are entirely left to a framework it might be sensible for pgloader to refrain from handling index unique names, that is achieved by using the \fIpreserve index names\fR option\.
.
.IP
The default is to \fIuniquify index names\fR\.
.
.IP
Even when using the option \fIpreserve index names\fR, MySQL primary key indexes named "PRIMARY" will get their names uniquified\. Failing to do so would prevent the primary keys to be created again in PostgreSQL where the index names must be unique per schema\.
.
.IP "\(bu" 4
\fIforeign keys\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIno foreign keys\fR
.
.IP
When this option is listed, pgloader skips creating foreign keys\.
.
.IP "\(bu" 4
\fIreset sequences\fR
.
.IP
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\.
.
.IP
The options \fIschema only\fR and \fIdata only\fR have no effects on this option\.
.
.IP "\(bu" 4
\fIreset no sequences\fR
.
.IP
When this option is listed, pgloader skips resetting sequences after the load\.
.
.IP
The options \fIschema only\fR and \fIdata only\fR have no effects on this option\.
.
.IP "\(bu" 4
\fIdowncase identifiers\fR
.
.IP
When this option is listed, pgloader converts all MySQL identifiers (table names, index names, column names) to \fIdowncase\fR, except for PostgreSQL \fIreserved\fR keywords\.
.
.IP
The PostgreSQL \fIreserved\fR keywords are determined dynamically by using the system function \fBpg_get_keywords()\fR\.
.
.IP "\(bu" 4
\fIquote identifiers\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIschema only\fR
.
.IP
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 \fIcreate indexes\fR has been listed\.
.
.IP "\(bu" 4
\fIdata only\fR
.
.IP
When this option is listed pgloader only issues the \fBCOPY\fR statements, without doing any other processing\.
.
.IP "" 0

.
.IP "\(bu" 4
\fICAST\fR
.
.IP
The cast clause allows to specify custom casting rules, either to overload the default casting rules or to amend them with special cases\.
.
.IP
A casting rule is expected to follow one of the forms:
.
.IP "" 4
.
.nf

type <mysql\-type\-name> [ <guard> \.\.\. ] to <pgsql\-type\-name> [ <option> \.\.\. ]
column <table\-name>\.<column\-name> [ <guards> ] to \.\.\.
.
.fi
.
.IP "" 0
.
.IP
It\'s possible for a \fIcasting rule\fR to either match against a MySQL data type or against a given \fIcolumn name\fR in a given \fItable name\fR\. That flexibility allows to cope with cases where the type \fBtinyint\fR might have been used as a \fBboolean\fR in some cases but as a \fBsmallint\fR in others\.
.
.IP
The \fIcasting rules\fR are applied in order, the first match prevents following rules to be applied, and user defined rules are evaluated first\.
.
.IP
The supported guards are:
.
.IP "\(bu" 4
\fIwhen default \'value\'\fR
.
.IP
The casting rule is only applied against MySQL columns of the source type that have given \fIvalue\fR, which must be a single\-quoted or a double\-quoted string\.
.
.IP "\(bu" 4
\fIwhen typemod expression\fR
.
.IP
The casting rule is only applied against MySQL columns of the source type that have a \fItypemod\fR value matching the given \fItypemod expression\fR\. The \fItypemod\fR is separated into its \fIprecision\fR and \fIscale\fR components\.
.
.IP
Example of a cast rule using a \fItypemod\fR guard:
.
.IP "" 4
.
.nf

type char when (= precision 1) to char keep typemod
.
.fi
.
.IP "" 0
.
.IP
This expression casts MySQL \fBchar(1)\fR column to a PostgreSQL column of type \fBchar(1)\fR while allowing for the general case \fBchar(N)\fR will be converted by the default cast rule into a PostgreSQL type \fBvarchar(N)\fR\.
.
.IP "\(bu" 4
\fIwith extra auto_increment\fR
.
.IP
The casting rule is only applied against MySQL columns having the \fIextra\fR column \fBauto_increment\fR option set, so that it\'s possible to target e\.g\. \fBserial\fR rather than \fBinteger\fR\.
.
.IP
The default matching behavior, when this option isn\'t set, is to match both columns with the extra definition and without\.
.
.IP
This means that if you want to implement a casting rule that target either \fBserial\fR or \fBinteger\fR from a \fBsmallint\fR definition depending on the \fIauto_increment\fR extra bit of information from MySQL, then you need to spell out two casting rules as following:
.
.IP "" 4
.
.nf

type smallint  with extra auto_increment
  to serial drop typemod keep default keep not null,
type smallint
  to integer drop typemod keep default keep not null
.
.fi
.
.IP "" 0

.
.IP "" 0
.
.IP
The supported casting options are:
.
.IP "\(bu" 4
\fIdrop default\fR, \fIkeep default\fR
.
.IP
When the option \fIdrop default\fR is listed, pgloader drops any existing default expression in the MySQL database for columns of the source type from the \fBCREATE TABLE\fR statement it generates\.
.
.IP
The spelling \fIkeep default\fR explicitly prevents that behaviour and can be used to overload the default casting rules\.
.
.IP "\(bu" 4
\fIdrop not null\fR, \fIkeep not null\fR, \fIset not null\fR
.
.IP
When the option \fIdrop not null\fR is listed, pgloader drops any existing \fBNOT NULL\fR constraint associated with the given source MySQL datatype when it creates the tables in the PostgreSQL database\.
.
.IP
The spelling \fIkeep not null\fR explicitly prevents that behaviour and can be used to overload the default casting rules\.
.
.IP
When the option \fIset not null\fR is listed, pgloader sets a \fBNOT NULL\fR constraint on the target column regardless whether it has been set in the source MySQL column\.
.
.IP "\(bu" 4
\fIdrop typemod\fR, \fIkeep typemod\fR
.
.IP
When the option \fIdrop typemod\fR is listed, pgloader drops any existing \fItypemod\fR definition (e\.g\. \fIprecision\fR and \fIscale\fR) from the datatype definition found in the MySQL columns of the source type when it created the tables in the PostgreSQL database\.
.
.IP
The spelling \fIkeep typemod\fR explicitly prevents that behaviour and can be used to overload the default casting rules\.
.
.IP "\(bu" 4
\fIusing\fR
.
.IP
This option takes as its single argument the name of a function to be found in the \fBpgloader\.transforms\fR Common Lisp package\. See above for details\.
.
.IP
It\'s possible to augment a default cast rule (such as one that applies against \fBENUM\fR data type for example) with a \fItransformation function\fR by omitting entirely the \fBtype\fR parts of the casting rule, as in the following example:
.
.IP "" 4
.
.nf

column enumerate\.foo using empty\-string\-to\-null
.
.fi
.
.IP "" 0

.
.IP "" 0

.
.IP "\(bu" 4
\fIMATERIALIZE VIEWS\fR
.
.IP
This clause allows you to implement custom data processing at the data source by providing a \fIview definition\fR against which pgloader will query the data\. It\'s not possible to just allow for plain \fBSQL\fR because we want to know a lot about the exact data types of each column involved in the query output\.
.
.IP
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:
.
.IP
\fIname\fR \fBAS\fR \fB$$\fR \fIsql query\fR \fB$$\fR
.
.IP
The \fIname\fR and the \fIsql query\fR will be used in a \fBCREATE VIEW\fR statement at the beginning of the data loading, and the resulting view will then be dropped at the end of the data loading\.
.
.IP "\(bu" 4
\fIMATERIALIZE ALL VIEWS\fR
.
.IP
Same behaviour as \fIMATERIALIZE VIEWS\fR using the dynamic list of views as returned by MySQL rather than asking the user to specify the list\.
.
.IP "\(bu" 4
\fIINCLUDING ONLY TABLE NAMES MATCHING\fR
.
.IP
Introduce a comma separated list of table names or \fIregular expression\fR used to limit the tables to migrate to a sublist\.
.
.IP
Example:
.
.IP "" 4
.
.nf

INCLUDING ONLY TABLE NAMES MATCHING ~/film/, \'actor\'
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIEXCLUDING TABLE NAMES MATCHING\fR
.
.IP
Introduce a comma separated list of table names or \fIregular expression\fR used to exclude table names from the migration\. This filter only applies to the result of the \fIINCLUDING\fR filter\.
.
.IP "" 4
.
.nf

EXCLUDING TABLE NAMES MATCHING ~<ory>
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIDECODING TABLE NAMES MATCHING\fR
.
.IP
Introduce a comma separated list of table names or \fIregular expressions\fR 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\.
.
.IP "" 4
.
.nf

DECODING TABLE NAMES MATCHING ~/messed/, ~/encoding/ AS utf8
.
.fi
.
.IP "" 0
.
.IP
You can use as many such rules as you need, all with possibly different encodings\.
.
.IP "\(bu" 4
\fIALTER TABLE NAMES MATCHING\fR
.
.IP
Introduce a comma separated list of table names or \fIregular expressions\fR that you want to target in the pgloader \fIALTER TABLE\fR command\. The only two available actions are \fISET SCHEMA\fR and \fIRENAME TO\fR, both take a quoted string as parameter:
.
.IP "" 4
.
.nf

ALTER TABLE NAMES MATCHING ~/_list$/, \'sales_by_store\', ~/sales_by/
 SET SCHEMA \'mv\'

ALTER TABLE NAMES MATCHING \'film\' RENAME TO \'films\'
.
.fi
.
.IP "" 0
.
.IP
You can use as many such rules as you need\. The list of tables to be migrated is searched in pgloader memory against the \fIALTER TABLE\fR matching rules, and for each command pgloader stops at the first matching criteria (regexp or string)\.
.
.IP
No \fIALTER TABLE\fR command is sent to PostgreSQL, the modification happens at the level of the pgloader in\-memory representation of your source database schema\. In case of a name change, the mapping is kept and reused in the \fIforeign key\fR and \fIindex\fR support\.
.
.IP "" 0
.
.SS "LIMITATIONS"
The \fBdatabase\fR command currently only supports MySQL source database and has the following limitations:
.
.IP "\(bu" 4
Views are not migrated,
.
.IP
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\.
.
.IP
While it\'s not theoretically impossible, don\'t hold your breath\.
.
.IP "\(bu" 4
Triggers are not migrated
.
.IP
The difficulty of doing so is not yet assessed\.
.
.IP "\(bu" 4
\fBON UPDATE CURRENT_TIMESTAMP\fR is currently not migrated
.
.IP
It\'s simple enough to implement, just not on the priority list yet\.
.
.IP "\(bu" 4
Of the geometric datatypes, only the \fBPOINT\fR database has been covered\. The other ones should be easy enough to implement now, it\'s just not done yet\.
.
.IP "" 0
.
.SS "DEFAULT MySQL CASTING RULES"
When migrating from MySQL the following Casting Rules are provided:
.
.P
Numbers:
.
.IP "\(bu" 4
type int with extra auto_increment to serial when (< precision 10)
.
.IP "\(bu" 4
type int with extra auto_increment to bigserial when (<= 10 precision)
.
.IP "\(bu" 4
type int to int when (< precision 10)
.
.IP "\(bu" 4
type int to bigint when (<= 10 precision)
.
.IP "\(bu" 4
type tinyint with extra auto_increment to serial
.
.IP "\(bu" 4
type smallint with extra auto_increment to serial
.
.IP "\(bu" 4
type mediumint with extra auto_increment to serial
.
.IP "\(bu" 4
type bigint with extra auto_increment to bigserial
.
.IP "\(bu" 4
type tinyint to boolean when (= 1 precision) using tinyint\-to\-boolean
.
.IP "\(bu" 4
type tinyint to smallint drop typemod
.
.IP "\(bu" 4
type smallint to smallint drop typemod
.
.IP "\(bu" 4
type mediumint to integer drop typemod
.
.IP "\(bu" 4
type integer to integer drop typemod
.
.IP "\(bu" 4
type float to float drop typemod
.
.IP "\(bu" 4
type bigint to bigint drop typemod
.
.IP "\(bu" 4
type double to double precision drop typemod
.
.IP "\(bu" 4
type numeric to numeric keep typemod
.
.IP "\(bu" 4
type decimal to decimal keep typemod
.
.IP "" 0
.
.P
Texts:
.
.IP "\(bu" 4
type char to char keep typemod using remove\-null\-characters
.
.IP "\(bu" 4
type varchar to varchar keep typemod using remove\-null\-characters
.
.IP "\(bu" 4
type tinytext to text using remove\-null\-characters
.
.IP "\(bu" 4
type text to text using remove\-null\-characters
.
.IP "\(bu" 4
type mediumtext to text using remove\-null\-characters
.
.IP "\(bu" 4
type longtext to text using remove\-null\-characters
.
.IP "" 0
.
.P
Binary:
.
.IP "\(bu" 4
type binary to bytea
.
.IP "\(bu" 4
type varbinary to bytea
.
.IP "\(bu" 4
type tinyblob to bytea
.
.IP "\(bu" 4
type blob to bytea
.
.IP "\(bu" 4
type mediumblob to bytea
.
.IP "\(bu" 4
type longblob to bytea
.
.IP "" 0
.
.P
Date:
.
.IP "\(bu" 4
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
.
.IP "\(bu" 4
type datetime when default "0000\-00\-00 00:00:00" to timestamptz drop default using zero\-dates\-to\-null
.
.IP "\(bu" 4
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
.
.IP "\(bu" 4
type timestamp when default "0000\-00\-00 00:00:00" to timestamptz drop default using zero\-dates\-to\-null
.
.IP "\(bu" 4
type date when default "0000\-00\-00" to date drop default using zero\-dates\-to\-null
.
.IP "\(bu" 4
type date to date
.
.IP "\(bu" 4
type datetime to timestamptz
.
.IP "\(bu" 4
type timestamp to timestamptz
.
.IP "\(bu" 4
type year to integer drop typemod
.
.IP "" 0
.
.P
Geometric:
.
.IP "\(bu" 4
type point to point using pgloader\.transforms::convert\-mysql\-point
.
.IP "" 0
.
.P
Enum types are declared inline in MySQL and separately with a \fBCREATE TYPE\fR 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
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\.
.
.SH "LOAD SQLite DATABASE"
This command instructs pgloader to load data from a SQLite file\. Automatic discovery of the schema is supported, including build of the indexes\.
.
.P
Here\'s an example:
.
.IP "" 4
.
.nf

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\';
.
.fi
.
.IP "" 0
.
.P
The \fBsqlite\fR command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Path or HTTP URL to a SQLite file, might be a \fB\.zip\fR file\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBSQLite\fR database, the following options are supported:
.
.IP
When loading from a \fBSQLite\fR database, the following options are supported, and the default \fIWITH\fR clause is: \fIno truncate\fR, \fIcreate tables\fR, \fIinclude drop\fR, \fIcreate indexes\fR, \fIreset sequences\fR, \fIdowncase identifiers\fR, \fIencoding \'utf\-8\'\fR\.
.
.IP "\(bu" 4
\fIinclude drop\fR
.
.IP
When this option is listed, pgloader drops all the tables in the target PostgreSQL database whose names appear 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\. Please note that \fBCASCADE\fR is used to ensure that tables are dropped even if there are foreign keys pointing to them\. This is precisely what \fBinclude drop\fR is intended to do: drop all target tables and recreate them\.
.
.IP
Great care needs to be taken when using \fBinclude drop\fR, as it will cascade to \fIall\fR objects referencing the target tables, possibly including other tables that are not being loaded from the source DB\.
.
.IP "\(bu" 4
\fIinclude no drop\fR
.
.IP
When this option is listed, pgloader will not include any \fBDROP\fR statement when loading the data\.
.
.IP "\(bu" 4
\fItruncate\fR
.
.IP
When this option is listed, pgloader issue the \fBTRUNCATE\fR command against each PostgreSQL table just before loading data into it\.
.
.IP "\(bu" 4
\fIno truncate\fR
.
.IP
When this option is listed, pgloader issues no \fBTRUNCATE\fR command\.
.
.IP "\(bu" 4
\fIdisable triggers\fR
.
.IP
When this option is listed, pgloader issues an \fBALTER TABLE \.\.\. DISABLE TRIGGER ALL\fR command against the PostgreSQL target table before copying the data, then the command \fBALTER TABLE \.\.\. ENABLE TRIGGER ALL\fR once the \fBCOPY\fR is done\.
.
.IP
This option allows loading data into a pre\-existing table ignoring the \fIforeign key constraints\fR and user defined triggers and may result in invalid \fIforeign key constraints\fR once the data is loaded\. Use with care\.
.
.IP "\(bu" 4
\fIcreate tables\fR
.
.IP
When this option is listed, pgloader creates the table using the meta data found in the \fBSQLite\fR file, which must contain a list of fields with their data type\. A standard data type conversion from DBF to PostgreSQL is done\.
.
.IP "\(bu" 4
\fIcreate no tables\fR
.
.IP
When this option is listed, pgloader skips the creation of table before loading data, target tables must then already exist\.
.
.IP
Also, when using \fIcreate no tables\fR pgloader fetches the metadata from the current target database and checks type casting, then will remove constraints and indexes prior to loading the data and install them back again once the loading is done\.
.
.IP "\(bu" 4
\fIcreate indexes\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIcreate no indexes\fR
.
.IP
When this option is listed, pgloader skips the creating indexes\.
.
.IP "\(bu" 4
\fIreset sequences\fR
.
.IP
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\.
.
.IP "\(bu" 4
\fIreset no sequences\fR
.
.IP
When this option is listed, pgloader skips resetting sequences after the load\.
.
.IP
The options \fIschema only\fR and \fIdata only\fR have no effects on this option\.
.
.IP "\(bu" 4
\fIschema only\fR
.
.IP
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 \fIcreate indexes\fR has been listed\.
.
.IP "\(bu" 4
\fIdata only\fR
.
.IP
When this option is listed pgloader only issues the \fBCOPY\fR statements, without doing any other processing\.
.
.IP "\(bu" 4
\fIencoding\fR
.
.IP
This option allows to control which encoding to parse the SQLite text data with\. Defaults to UTF\-8\.
.
.IP "" 0

.
.IP "\(bu" 4
\fICAST\fR
.
.IP
The cast clause allows to specify custom casting rules, either to overload the default casting rules or to amend them with special cases\.
.
.IP
Please refer to the MySQL CAST clause for details\.
.
.IP "\(bu" 4
\fIINCLUDING ONLY TABLE NAMES LIKE\fR
.
.IP
Introduce a comma separated list of table name patterns used to limit the tables to migrate to a sublist\.
.
.IP
Example:
.
.IP "" 4
.
.nf

INCLUDING ONLY TABLE NAMES LIKE \'Invoice%\'
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIEXCLUDING TABLE NAMES LIKE\fR
.
.IP
Introduce a comma separated list of table name patterns used to exclude table names from the migration\. This filter only applies to the result of the \fIINCLUDING\fR filter\.
.
.IP "" 4
.
.nf

EXCLUDING TABLE NAMES LIKE \'appointments\'
.
.fi
.
.IP "" 0

.
.IP "" 0
.
.SS "DEFAULT SQLite CASTING RULES"
When migrating from SQLite the following Casting Rules are provided:
.
.P
Numbers:
.
.IP "\(bu" 4
type tinyint to smallint using integer\-to\-string
.
.IP "\(bu" 4
type integer to bigint using integer\-to\-string
.
.IP "\(bu" 4
type float to float using float\-to\-string
.
.IP "\(bu" 4
type real to real using float\-to\-string
.
.IP "\(bu" 4
type double to double precision using float\-to\-string
.
.IP "\(bu" 4
type numeric to numeric using float\-to\-string
.
.IP "" 0
.
.P
Texts:
.
.IP "\(bu" 4
type character to text drop typemod
.
.IP "\(bu" 4
type varchar to text drop typemod
.
.IP "\(bu" 4
type nvarchar to text drop typemod
.
.IP "\(bu" 4
type char to text drop typemod
.
.IP "\(bu" 4
type nchar to text drop typemod
.
.IP "\(bu" 4
type nvarchar to text drop typemod
.
.IP "\(bu" 4
type clob to text drop typemod
.
.IP "" 0
.
.P
Binary:
.
.IP "\(bu" 4
type blob to bytea
.
.IP "" 0
.
.P
Date:
.
.IP "\(bu" 4
type datetime to timestamptz using sqlite\-timestamp\-to\-timestamp
.
.IP "\(bu" 4
type timestamp to timestamptz using sqlite\-timestamp\-to\-timestamp
.
.IP "\(bu" 4
type timestamptz to timestamptz using sqlite\-timestamp\-to\-timestamp
.
.IP "" 0
.
.SH "LOAD MS SQL DATABASE"
This command instructs pgloader to load data from a MS SQL database\. Automatic discovery of the schema is supported, including build of the indexes, primary and foreign keys constraints\.
.
.P
Here\'s an example:
.
.IP "" 4
.
.nf

load database
     from mssql://user@host/dbname
     into postgresql:///dbname

including only table names like \'GlobalAccount\' in schema \'dbo\'

set work_mem to \'16MB\', maintenance_work_mem to \'512 MB\'

before load do $$ drop schema if exists dbo cascade; $$;
.
.fi
.
.IP "" 0
.
.P
The \fBmssql\fR command accepts the following clauses and options:
.
.IP "\(bu" 4
\fIFROM\fR
.
.IP
Connection string to an existing MS SQL database server that listens and welcome external TCP/IP connection\. As pgloader currently piggybacks on the FreeTDS driver, to change the port of the server please export the \fBTDSPORT\fR environment variable\.
.
.IP "\(bu" 4
\fIWITH\fR
.
.IP
When loading from a \fBMS SQL\fR database, the same options as when loading a \fBMySQL\fR database are supported\. Please refer to the MySQL section\. The following options are added:
.
.IP "\(bu" 4
\fIcreate schemas\fR
.
.IP
When this option is listed, pgloader creates the same schemas as found on the MS SQL instance\. This is the default\.
.
.IP "\(bu" 4
\fIcreate no schemas\fR
.
.IP
When this option is listed, pgloader refrains from creating any schemas at all, you must then ensure that the target schema do exist\.
.
.IP "" 0

.
.IP "\(bu" 4
\fICAST\fR
.
.IP
The cast clause allows to specify custom casting rules, either to overload the default casting rules or to amend them with special cases\.
.
.IP
Please refer to the MySQL CAST clause for details\.
.
.IP "\(bu" 4
\fIINCLUDING ONLY TABLE NAMES LIKE \'\.\.\.\' [, \'\.\.\.\'] IN SCHEMA \'\.\.\.\'\fR
.
.IP
Introduce a comma separated list of table name patterns used to limit the tables to migrate to a sublist\. More than one such clause may be used, they will be accumulated together\.
.
.IP
Example:
.
.IP "" 4
.
.nf

including only table names lile \'GlobalAccount\' in schema \'dbo\'
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIEXCLUDING TABLE NAMES LIKE \'\.\.\.\' [, \'\.\.\.\'] IN SCHEMA \'\.\.\.\'\fR
.
.IP
Introduce a comma separated list of table name patterns used to exclude table names from the migration\. This filter only applies to the result of the \fIINCLUDING\fR filter\.
.
.IP "" 4
.
.nf

EXCLUDING TABLE NAMES MATCHING \'LocalAccount\' in schema \'dbo\'
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIALTER SCHEMA \'\.\.\.\' RENAME TO \'\.\.\.\'\fR
.
.IP
Allows to rename a schema on the flight, so that for instance the tables found in the schema \'dbo\' in your source database will get migrated into the schema \'public\' in the target database with this command:
.
.IP "" 4
.
.nf

ALTER SCHEMA \'dbo\' RENAME TO \'public\'
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIALTER TABLE NAMES MATCHING \.\.\. IN SCHEMA \'\.\.\.\'\fR
.
.IP
See the MySQL explanation for this clause above\. It works the same in the context of migrating from MS SQL, only with the added option to specify the name of the schema where to find the definition of the target tables\.
.
.IP
The matching is done in pgloader itself, with a Common Lisp regular expression lib, so doesn\'t depend on the \fILIKE\fR implementation of MS SQL, nor on the lack of support for regular expressions in the engine\.
.
.IP "" 0
.
.SS "DEFAULT MS SQL CASTING RULES"
When migrating from MS SQL the following Casting Rules are provided:
.
.P
Numbers:
.
.IP "\(bu" 4
type tinyint to smallint
.
.IP "\(bu" 4
type float to float using float\-to\-string
.
.IP "\(bu" 4
type real to real using float\-to\-string
.
.IP "\(bu" 4
type double to double precision using float\-to\-string
.
.IP "\(bu" 4
type numeric to numeric using float\-to\-string
.
.IP "\(bu" 4
type decimal to numeric using float\-to\-string
.
.IP "\(bu" 4
type money to numeric using float\-to\-string
.
.IP "\(bu" 4
type smallmoney to numeric using float\-to\-string
.
.IP "" 0
.
.P
Texts:
.
.IP "\(bu" 4
type char to text drop typemod
.
.IP "\(bu" 4
type nchat to text drop typemod
.
.IP "\(bu" 4
type varchar to text drop typemod
.
.IP "\(bu" 4
type nvarchar to text drop typemod
.
.IP "\(bu" 4
type xml to text drop typemod
.
.IP "" 0
.
.P
Binary:
.
.IP "\(bu" 4
type binary to bytea using byte\-vector\-to\-bytea
.
.IP "\(bu" 4
type varbinary to bytea using byte\-vector\-to\-bytea
.
.IP "" 0
.
.P
Date:
.
.IP "\(bu" 4
type datetime to timestamptz
.
.IP "\(bu" 4
type datetime2 to timestamptz
.
.IP "" 0
.
.P
Others:
.
.IP "\(bu" 4
type bit to boolean
.
.IP "\(bu" 4
type hierarchyid to bytea
.
.IP "\(bu" 4
type geography to bytea
.
.IP "\(bu" 4
type uniqueidentifier to uuid using sql\-server\-uniqueidentifier\-to\-uuid
.
.IP "" 0
.
.SH "TRANSFORMATION FUNCTIONS"
Some data types are implemented in a different enough way that a transformation function is necessary\. This function must be written in \fBCommon lisp\fR and is searched in the \fBpgloader\.transforms\fR package\.
.
.P
Some default transformation function are provided with pgloader, and you can use the \fB\-\-load\fR 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:
.
.IP "" 4
.
.nf

(in\-package #:pgloader\.transforms)
.
.fi
.
.IP "" 0
.
.P
The provided transformation functions are:
.
.IP "\(bu" 4
\fIzero\-dates\-to\-null\fR
.
.IP
When the input date is all zeroes, return \fBnil\fR, which gets loaded as a PostgreSQL \fBNULL\fR value\.
.
.IP "\(bu" 4
\fIdate\-with\-no\-separator\fR
.
.IP
Applies \fIzero\-dates\-to\-null\fR then transform the given date into a format that PostgreSQL will actually process:
.
.IP "" 4
.
.nf

In:  "20041002152952"
Out: "2004\-10\-02 15:29:52"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fItime\-with\-no\-separator\fR
.
.IP
Transform the given time into a format that PostgreSQL will actually process:
.
.IP "" 4
.
.nf

In:  "08231560"
Out: "08:23:15\.60"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fItinyint\-to\-boolean\fR
.
.IP
As MySQL lacks a proper boolean type, \fItinyint\fR is often used to implement that\. This function transforms \fB0\fR to \fB\'false\'\fR and anything else to \fB\'true\fR\'\.
.
.IP "\(bu" 4
\fIbits\-to\-boolean\fR
.
.IP
As MySQL lacks a proper boolean type, \fIBIT\fR is often used to implement that\. This function transforms 1\-bit bit vectors from \fB0\fR to \fBf\fR and any other value to \fBt\fR\.\.
.
.IP "\(bu" 4
\fIint\-to\-ip\fR
.
.IP
Convert an integer into a dotted representation of an ip4\.
.
.IP "" 4
.
.nf

In:  18435761
Out: "1\.25\.78\.177"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIip\-range\fR
.
.IP
Converts a couple of integers given as strings into a range of ip4\.
.
.IP "" 4
.
.nf

In:  "16825344" "16825599"
Out: "1\.0\.188\.0\-1\.0\.188\.255"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIconvert\-mysql\-point\fR
.
.IP
Converts from the \fBastext\fR representation of points in MySQL to the PostgreSQL representation\.
.
.IP "" 4
.
.nf

In:  "POINT(48\.5513589 7\.6926827)"
Out: "(48\.5513589,7\.6926827)"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIinteger\-to\-string\fR
.
.IP
Converts a integer string or a Common Lisp integer into a string suitable for a PostgreSQL integer\. Takes care of quoted integers\.
.
.IP "" 4
.
.nf

In:  "\e"0\e""
Out: "0"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIfloat\-to\-string\fR
.
.IP
Converts a Common Lisp float into a string suitable for a PostgreSQL float:
.
.IP "" 4
.
.nf

In:  100\.0d0
Out: "100\.0"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIset\-to\-enum\-array\fR
.
.IP
Converts a string representing a MySQL SET into a PostgreSQL Array of Enum values from the set\.
.
.IP "" 4
.
.nf

In: "foo,bar"
Out: "{foo,bar}"
.
.fi
.
.IP "" 0

.
.IP "\(bu" 4
\fIempty\-string\-to\-null\fR
.
.IP
Convert an empty string to a null\.
.
.IP "\(bu" 4
\fIright\-trim\fR
.
.IP
Remove whitespace at end of string\.
.
.IP "\(bu" 4
\fIremove\-null\-characters\fR
.
.IP
Remove \fBNUL\fR characters (\fB0x0\fR) from given strings\.
.
.IP "\(bu" 4
\fIbyte\-vector\-to\-bytea\fR
.
.IP
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
.
.IP "\(bu" 4
\fIsqlite\-timestamp\-to\-timestamp\fR
.
.IP
SQLite type system is quite interesting, so cope with it here to produce timestamp literals as expected by PostgreSQL\. That covers year only on 4 digits, 0 dates to null, and proper date strings\.
.
.IP "\(bu" 4
\fIsql\-server\-uniqueidentifier\-to\-uuid\fR
.
.IP
The SQL Server driver receives data fo type uniqueidentifier as byte vector that we then need to convert to an UUID string for PostgreSQL COPY input format to process\.
.
.IP "\(bu" 4
\fIunix\-timestamp\-to\-timestamptz\fR
.
.IP
Converts a unix timestamp (number of seconds elapsed since beginning of 1970) into a proper PostgreSQL timestamp format\.
.
.IP "\(bu" 4
\fIvarbinary\-to\-string\fR
.
.IP
Converts binary encoded string (such as a MySQL \fBvarbinary\fR entry) to a decoded text, using the table\'s encoding that may be overloaded with the \fIDECODING TABLE NAMES MATCHING\fR clause\.
.
.IP "" 0
.
.SH "LOAD MESSAGES"
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\.
.
.IP "" 4
.
.nf

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;
.
.fi
.
.IP "" 0
.
.P
As the command is still experimental the options might be changed in the future and the details are not documented\.
.
.SH "AUTHOR"
Dimitri Fontaine \fIdimitri@2ndQuadrant\.fr\fR
.
.SH "SEE ALSO"
PostgreSQL COPY documentation at \fIhttp://www\.postgresql\.org/docs/9\.3/static/sql\-copy\.html\fR\.
.
.P
The pgloader source code, binary packages, documentation and examples may be downloaded from \fIhttp://pgloader\.io/\fR\.