Commit Graph

49 Commits

Author SHA1 Message Date
Dimitri Fontaine
ad8fb0b2a4 Implement machine readable summary files, fixes #144.
It's now possible to have pgloader print out its summary in one of
several formats: human-readable (default), csv, copy or json. The
choice of format is made depending on the extension of the summary
filename picked on the command line with the option --summary.
2015-01-06 01:22:01 +01:00
Dimitri Fontaine
d9f5bff5e0 Cleanup some code location. 2015-01-06 01:18:54 +01:00
Dimitri Fontaine
a86369a03d Improve the CLI situation a bit.
Fix bugs related to parsing the new COPY type, and make it so that we
know how to parse options (and fields, and other type dependant things)
even when --type is missing, in care the source URL has the information.
2015-01-06 00:07:31 +01:00
Dimitri Fontaine
e1bc6425e2 Implement support for PostgreSQL COPY format, fix #145.
PostgreSQL COPY format is not really CSV but something way easier to
parse. Funnily enough, parsing it as CSV is not that easy, so we add
here a special simple parser for the COPY format.

It should be quite useful too try loading again reject data files from
pgloader after manual fixing, too. It's still missing some documentation
without any good excuse for that, will add soon.
2015-01-02 18:49:17 +01:00
Dimitri Fontaine
40f3c4f769 Improve HTTP handling of CSV and Fixed data sources.
In passing also allow --field to specify the whole field list, there's
no point in forcing the user to have as many --field switches on the
command line as they have columns in their data source file.
2014-12-27 17:02:19 +01:00
Dimitri Fontaine
302a7d402b Refactor connection handling, and clean-up many things.
That's the big refactoring patch I've been sitting on for too long.

First, refactor connection handling to use a uniformed "connection"
concept (class and generic functions API) everywhere, so that the COPY
derived objects just use that in their :source-db and :target-db slots.

Given that, we don't need no messing around with *pgconn* and *myconn-*
and other special variables at all anywhere in the tree.

Second, clean up some oddities accumulated over time, where some parts
of the code didn't get the memo when new API got into place.

Third, fix any other oddity or missing part found while doing those
first two activities, it was long overdue anyway...
2014-12-26 21:50:29 +01:00
Dimitri Fontaine
3362a1da19 Improve source and target uri parsing.
In particular, make dbf and db3 synonyms as far as --type is concerned.
2014-12-23 17:32:55 +01:00
Dimitri Fontaine
6eac0d9dd8 Implement --before and --after options on the command line.
That allows using SQL scripts to run before and after the main data
processing and loading done by pgloader when used only from the command
line.
2014-12-23 12:21:44 +01:00
Dimitri Fontaine
65c2043694 Improve pgloader usage from the command line.
Make it so that the following command line usages are accepted when
using pgloader without a command file:

 ./build/bin/pgloader ./test/sqlite/sqlite.db postgresql:///pgloader

 ./build/bin/pgloader --set "search_path='sakila'"  \
                      mysql://root@localhost/sakila \
                 postgresql:///sakila

 ./build/bin/pgloader --type csv                             \
                      --field id --field field               \
                      --with truncate                        \
                      --with "fields terminated by ','"      \
                      ./test/data/matching-1.csv             \
                      postgres:///pgloader?matching

It's now possible in most cases to just use command-line options, which
should make the entry bar to pgloader much lower.
2014-12-23 02:40:13 +01:00
Dimitri Fontaine
ed853a7bea Allow pgloader to work on windows. 2014-11-06 22:12:20 +01:00
Dimitri Fontaine
4916e67a9e Fix --root-dir debian reported bug #767288 2014-11-03 14:08:51 +01:00
Dimitri Fontaine
9c604f969b Rename --load into --load-lisp-file
To avoid wasting everybody's time when trying to debug --load
command.load, rename the option to be more explicit about what it does.
Also implement some basic guards in the form of testing that the
filename extension is part of a very short whitelist: .lisp, .cl, .lsp
and .asd.
2014-09-02 22:33:51 +02:00
Dimitri Fontaine
a41f8ea6d3 Create root-dir when it does not exists, fix #35. 2014-08-29 23:19:01 +02:00
Dimitri Fontaine
d00837f8fc Fix --upgrade-config basic usage. 2014-07-13 16:35:53 +02:00
Dimitri Fontaine
de4ff30acc Implement --summary to copy the output to a file, fix #68.
Given than redirecting a tty such as *terminal-io* isn't easy enough,
let's provide a way to copy the summary output to a file. Another way to
solve it would have been to output the summary to the main logs, but
that could have made the logs parsing more difficult that necessary.

Let's see how users like it...
2014-06-14 23:31:11 +02:00
Dimitri Fontaine
e93ba8b887 Fix handling --client-min-messages and --log-min-messages.
Should help with issue #67 by allowing --client-min-messages to
effectively control entering the debugger in case of unhandled
conditions, etc.

Contrary to the discussion, in this patch --log-min-messages has no
impact on the behavior of the console and interactive behaviors.
2014-05-28 16:37:38 +02:00
Dimitri Fontaine
6e58db2994 Improve self-upgrading.
There's no reason not to parse again the command line with the newly
loaded code actually, so be sure to do the self-upgrade dance first
thing and recurse to the pgloader::main function (with a guard).
2014-05-03 15:22:34 +02:00
Dimitri Fontaine
fecae2c2d9 Implement --self-upgrade capacity.
As from now, to install a new version of pgloader when you have an older
one, say because there's that bug that got fixed meanwhile, all you need
to do is run

  $ git clone https://github.com/dimitri/pgloader.git /tmp/pgloader
  $ pgloader --self-upgrade /tmp/pgloader <options as usual>

Any Common Lisp developper using the product is already doing that many
times a day, it might prove useful for users to be able to hot-patch
themselves too, after all.
2014-05-03 00:25:44 +02:00
Dimitri Fontaine
c0d9bb4d8f Allows to build pgloader image using CCL.
Too many Makefile commands where hard-coded using SBCL, which prevented
from building successfully against CCL. That's now fixed.
2014-04-29 11:47:22 +02:00
Dimitri Fontaine
35ca4927e9 Get rid of some lib dependencies.
The charset business isn't worth depending on an AGPL licenced lib which
is part of a huge Quicklisp system.
2014-04-25 17:21:11 +02:00
Dimitri Fontaine
ceec4780f2 Improve log message pointing to the log file (use the true name). 2014-01-26 21:25:27 +01:00
Dimitri Fontaine
ca0d25d3b2 Provide a new log level, :data, activated when both --debug and --verbose are used. 2014-01-26 17:49:20 +01:00
Dimitri Fontaine
e92f085b04 Convert --root-dir to its truename before processing it, and manage errors to do so. 2014-01-24 15:10:45 +01:00
Dimitri Fontaine
69b550a46e Make use of the new usage function... 2014-01-24 10:14:51 +01:00
Dimitri Fontaine
be4cc804c0 Show usage and help when the command line options are not recognized. 2014-01-24 09:22:02 +01:00
Dimitri Fontaine
d132bafc07 Refrain from parsing a non-existing command file... 2014-01-23 23:17:34 +01:00
Dimitri Fontaine
aa49e8eec2 Fix the log-filename when operating from the command line. 2014-01-15 22:48:45 +01:00
Dimitri Fontaine
f2bec5fcd1 Fix the main command line "driver" to use the new with-monitor API. 2013-12-24 19:54:22 +01:00
Dimitri Fontaine
aca04b1514 Fix problem found when trying to load the code with CCL. 2013-12-19 23:08:02 +01:00
Dimitri Fontaine
32d91d7054 Return a non-zero error code to the OS when something unexpected did happen. 2013-11-25 11:25:57 +01:00
Dimitri Fontaine
c482015248 Arrange to error out when given non-existing file names in the command line. 2013-11-23 21:36:22 +01:00
Dimitri Fontaine
2a344ab7ce Add a usage line in the --help output. 2013-11-22 11:23:15 +01:00
Dimitri Fontaine
1419a1f65d Default --logfile to pgloader.log within --root-dir. 2013-11-21 14:28:11 +01:00
Dimitri Fontaine
516bb28ec0 Fix using TMPDIR from the environment when running from the binary image. 2013-11-21 13:06:16 +01:00
Dimitri Fontaine
d70ed07b12 If --lofgile is relative, expand it into --root-dir. 2013-11-21 12:56:54 +01:00
Dimitri Fontaine
febbc03459 Review some log messages and levels. 2013-11-21 11:37:47 +01:00
Dimitri Fontaine
d52240a95e Review the --root-dir patches for better default management.
Also ensure the directory we're given actually exists on disk, creating it
if necessary, and bail out early in case for whatever reason it's not
possible to create the directory.
2013-11-21 11:27:54 +01:00
Cédric Villemain
081f6be0b4 Add new command line parameter for root-dir
This variable replaces reject-root-path and is used to set the root working
directory.

It defaults to /tmp/pgloader/ like previously.

Also set the logfile according to the root-dir.

TODO: tmpdir is not handled in comand-line. Is it really wanted to have more
command line parameters ?
2013-11-21 11:00:02 +01:00
Cédric Villemain
8984a0a810 Rename reject-root-path to root-dir
Prepare the variable to be a parameter
2013-11-21 11:00:01 +01:00
Dimitri Fontaine
d295001a2a Review the main function to better handle per-filename-argument errors. 2013-11-17 19:02:26 +01:00
Dimitri Fontaine
cefd19d704 Improve handling of unhandled conditions, avoid entering the interactive debugger. 2013-11-15 18:03:06 +01:00
Dimitri Fontaine
59d8188ad0 Implement --log-min-messages and --client-min-messages for more control. 2013-11-08 21:53:21 +01:00
Dimitri Fontaine
55940a5a64 Add some more debug information. 2013-11-07 23:18:09 +01:00
Dimitri Fontaine
a9d160dc32 Some more error handling. 2013-11-07 23:17:00 +01:00
Dimitri Fontaine
186be010dc Fix the previous hasty commit. 2013-11-07 22:41:51 +01:00
Dimitri Fontaine
dfe4af5a48 Switch to handler-bind for proper stack-trace in case of the unexpected. 2013-11-07 22:40:07 +01:00
Dimitri Fontaine
a227943012 Fix the logging system, we now have a proper logfile. 2013-11-07 20:46:47 +01:00
Dimitri Fontaine
5ce5d53d7d Use trivial-backtrace to display more useful information in case of unexpected events, hopefully. 2013-11-07 20:14:06 +01:00
Dimitri Fontaine
fb818ee0e3 Move sources into their own subdirectory, assorted cleaning. 2013-10-20 19:09:09 +02:00