From: | Shaozhong SHI <shishaozhong(at)gmail(dot)com> |
---|---|
To: | Christian Ramseyer <ramseyer(at)netnea(dot)com> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: PostgreSQL CHECK Constraint |
Date: | 2021-10-03 18:53:51 |
Message-ID: | CA+i5JwYT43QfF69CWaod7xwVHpV4Uen9A3QsjNE2385jL9Y5PA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Hi, Christian,
Brilliant!
Some years ago, I did something similar and saved problematic ones for data
collector.
Now, I am reviewing to see whether there be any elegant way to automate
reporting and giving feedback.
Regards,
David
On Sunday, 3 October 2021, Christian Ramseyer <ramseyer(at)netnea(dot)com> wrote:
> > The reported error looks like this:
> >
> > postgres(at)dellstore ERROR: new row for relation "test_customers"
> > violates check constraint "check_age"
> ..
> >
> > This errors appears in the serverlog which has many format and
> > forwarding options, you can read about them here:
>
> On 03.10.21 20:16, Shaozhong SHI wrote:
> > Hi, Christian,
> > That is interesting. Can errors be captured and saved as data with
> > scripting?
>
> Yes that works quite the same, e.g. in Python you can do
>
> try:
> cur.execute("insert into test_customers (firstname, lastname, age)
> values ( %s, %s, %s)", ("Bobby", "Tables", 10))
> except psycopg2.errors.CheckViolation as e:
> print(f"That didn't work: {e.cursor.query} failed")
> print(f"{e.pgerror}")
>
>
> HTH
>
From | Date | Subject | |
---|---|---|---|
Next Message | Karsten Hilbert | 2021-10-03 18:56:15 | Re: PostgreSQL CHECK Constraint |
Previous Message | Christian Ramseyer | 2021-10-03 18:47:28 | Re: PostgreSQL CHECK Constraint |
From | Date | Subject | |
---|---|---|---|
Next Message | Karsten Hilbert | 2021-10-03 18:56:15 | Re: PostgreSQL CHECK Constraint |
Previous Message | Christian Ramseyer | 2021-10-03 18:47:28 | Re: PostgreSQL CHECK Constraint |