0

I am building a web-scraper which pulls data from websites and store it in database table . Primary key of the table is {timestamp+websitename} . Where timestap taken from that website . This happen in every 30 mins .

There are two possiblities a) I pulled the same data gain b) The content got edited on that website but still primary key remain same since creation time (timestap of this post) and website name remain unchanged.

Now I don't want to check using PHP weather same primary key exist or not. I just want data to get pushed into the database without giving me integrity constrain error . I want to do it for efficiency . Is there a way to do it in Mysql ? .

In simple words if row with same primary key already exist simply replace it with the current without throwing integrity constrain at me .

2 Answers 2

2

Yes, with REPLACE INTO statements.

A nice summary and caveats are described here

Sign up to request clarification or add additional context in comments.

Comments

0

if you use simple insert, take a look: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.