Updating records in MySQL

Support for DataSlave

Moderators: Tom, ian

Updating records in MySQL

Postby phrenetic » Sun Jul 08, 2012 9:03 pm

I am trying to read in a text file and update a MySQL database.

New data should be added to the database, existing data should be updated.

However, whenever I try to load a file containing data that already exists in the MySQL database, I get an error saying "Duplicate entry XXXXX for key PRIMARY" and the load operation aborts.

So, it looks as if it is trying to insert another record (resulting in a duplicated primary key) rather than updating the existing record.

How can I get the map to update my existing data?

Posts: 7
Joined: Wed Oct 12, 2011 9:56 pm

Re: Updating records in MySQL

Postby ian » Fri Jul 13, 2012 7:27 am

You need to ensure that the columns that is the primary key is identified. Pass the data through a Transform, using the Auto-Map to pass the data straight through. Then edit the Schema with the button on the top right. This allows you to define the Primary key.

DataSlave will then use the primary column to check for a matching record and use an UPDATE rather than an INSERT.

There are other posts that discuss this issue. For example please look at:

Posts: 364
Joined: Sat Dec 18, 2004 8:13 am
Location: UK

Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests