M
M
Mikhail Vasiltsev2018-02-13 20:03:23
SQL
Mikhail Vasiltsev, 2018-02-13 20:03:23

How to update the data in the database?

I get 130 products via API from another resource and put them into a table in the database. Then, about once a week, I need to make a new request to the API, receive goods, and if there are any changes, then I need to update the database. The question is how?
The easiest option, of course, is to delete everything from the table and fill it with a new one with up-to-date data. Or do it like this:
if(number of goods in the database != number received from the server), but this is so-so, because for example, 2 products can be removed and 2 added, and you get the same 130, but the content is slightly different.
Or another option is to get an array of data from the database and compare it for equivalence with the array received from the API, although I don’t know if there are functions that do this (multidimensional arrays).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2018-02-15
@d-stream

Fancy it would look like this:
- a temporary table where fresh data is "sucked in",
- (optionally) a certain tool for visual control of the correctness of the data and comparison with the current ones
- updating the differing ones (with marks of what exactly to change)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question