SF Markus Elfring <elfr...@users.sourceforge.net> wrote:

> Now I stumble on an error message like the following.
> ...
>    cursor.executemany(statement, parameters)
> sqlalchemy.exc.IntegrityError: (IntegrityError) UNIQUE constraint failed: 
> positions.function, 
> ...
> 
> 
> The message might be appropriate in principle for my concrete use case.
> But I observe that the constraint violation is reported a bit
> too late because I got the impression from corresponding debug
> output that three rows were added to the shown table here
> with unique attributes.
> 
> I would appreciate your explanations and further advices.

SQLAlchemy sends to the log the statement and parameters it is to send to the 
DBAPI cursor.execute() method, *before* it actually does so.  This so that if 
the DBAPI throws an exception, as is the case here, one can see what 
instructions were sent to it which were the immediate cause of this error.

The mechanism of a UNIQUE constraint is that this is a database-level 
construct, so the backend database is tasked with checking this condition and 
reporting on it at statement execution time.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to