[gdal-dev] Fwd: Catching many errors of the same record (ogr2ogr)

Paolo Cavallini cavallini at faunalia.it
Thu Jan 14 07:14:55 PST 2021


Hi Even, all,

> On vendredi 8 janvier 2021 15:58:39 CET matteo wrote:
>> Hi all,
>>
>> I've 2 small questions during a syncing from a GPKG to a PG DB with
>> constraints using -skipfailures:
>>
>> * is it possible to show only the constraint error and not also the
>> insert one? Even if there is only a single error, reading the log it
>> seems that there are 2 of them (I know a person should only read....)
>> * is there are 2 errors (e.g. constraints error) BUT in the same record,
>> ogr2ogr shows only the first one and not all of them
> 
> Why not experimenting outside GDAL a bit ?
> 
> $ psql
> 
> # create table foo(bar integer check (bar = 1), baz integer check (baz =
> 1));
> # insert into foo values (2,2);
> ERROR:  new row for relation "foo" violates check constraint
> "foo_bar_check"
> DETAIL:  Failing row contains (2, 2).
> 
> 
> and asking your favorite search engine about
> "postgresql get all constraint violations"
> 
> ==>
> https://stackoverflow.com/questions/23822162/error-message-with-all-constraint-violations-in-postgres

thanks Evan for this reply. The approach you suggested work well for an
interactive session, but not if one wants to write a little script
importing a set of layers and sending all the errors to the user. in
this case:
* reducing verbosity would make things more clear for the user
* listing all errors (non only all failing records, the first error per
record, as -skipfailures does, but all failing values for each record)
would be important to provide the user a list of issues to fix before
resubmitting the layer to import.
I have studied ogr2ogr man, but I do not find a way to solve either of
these problems. From your reply I assume this is a limitation of the pg
provider. Am I wrong? Is there a way to circumvent this?
Thanks a lot.
All the best.

-- 
Paolo Cavallini
www.faunalia.eu - QGIS.org
training, support, development on QGIS, PostGIS and more


More information about the gdal-dev mailing list