ERROR DB Writer Execute failed: Duplicate entry ‘’ for key ‘PRIMARY’

Hey KNIME community

I need help please !

Indeed, I try to insert rows into an MySQL table with the “DB Writer” node
The table in destination is empty and without primary key only index
But each time I execute my dataflow the same error coming:

ERROR DB Writer Execute failed: Duplicate entry ‘’ for key ‘PRIMARY’

Below my dataflow

Node 26

Node 27 Settings tab

How is it possible ? Have you any idea ?

Thanks a lot !

Hi,
Are you quite sure there is no primary key? Can you share the output of SHOW CREATE TABLE your-table-name? This should tell us more about the existing table and its indexes.
Kind regards
Alexander

Hi Alexander

Yes no primary key

The error message is the same with user id number

After few tests, it seems to be the last row contains on node26 always in error

For information I can delete row with “DB Delete” node

I really don’t understant

Could you show us the SQL you entered when you created the table? (Maybe you still have it in a working document or a MySQLWorkbench document?)

The error message being generated is actually coming out of MySQL (it’s error code 1062) - so the database is really under them impression that you’ve assigned a PRIMARY constraint to one or more columns.

In lieu of there being a way in KNIME to turn on some sort of logging which lists the INSERT transactions being sent to your database, perhaps you could turn on logging in your database to see what problem INSERTs are?

(Also, have you, for testing, assured that the table is totally empty before running the workflow? And once the workflow runs like this and fails, have you then in some other application (like command line mysql) verified that the table is still empty? (If there was a single batch INSERT that failed on the KNIME side, I believe the transaction is rolled back.))

2 Likes

This is a ‘user’ table, therefore I would EXPECT at least the user_id & likely user_name to be required to be unique. Which means there needs to be some sort of primary key defined in order to prevent collisions.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.