I’m fetching data from a text file or log periodically and it gets inserted in the database every time fetched. Is there a way in MySQL that the insert is only done when the log files are updated or I have to do it using the programming language ? I mean Is there a type of insert that when It sees a duplicate primary key, It doesn’t give an error of “Duplicate Entry” .. It just ignore.
Share
Put the fetch in a
logrotatepostrotate script, and fetch from the just rotated log.Ignoring duplicates can be done with either
INSERT IGNOREORINSERT .... ON DUPLICATE KEY UPDATEsyntax (which will either ignore the lines causing a duplcate unique key, or give you the possibility to alter some values in the existing row.)