Best way to sync with external database

What is the best way to sync my rails model with an external database ?

I can use a callback on my model to update the external table. But in
the other direction, when the external db change some data and would
sync my activerecord model ? I can only think at a REST request of
update of some record. Or a cron sync script, problematic with large db.
There’s better solutions ?

thanks.

Matteo F. wrote in post #967435:

What is the best way to sync my rails model with an external database ?

What exactly is your use case for this? It’s hard to give advice on a
question that vague.

I can use a callback on my model to update the external table. But in
the other direction, when the external db change some data and would
sync my activerecord model ? I can only think at a REST request of
update of some record. Or a cron sync script, problematic with large db.
There’s better solutions ?

From the little you’ve said, REST sounds like a good solution.

But…why do you need to synchronize at all? Can you just query the
external DB as necessary and avoid duplicating the data?

thanks.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Thu, Dec 9, 2010 at 11:07 AM, Matteo F. [email protected]
wrote:

the only time you need to reload the models is if the schema of the db
changes, any other time it the data changes rails will always pull the
latest data, it appears that what you want to know is how to update the
view
when the database changes. is that so ?

Marnen Laibow-Koser wrote in post #967437:

Matteo F. wrote in post #967435:

What is the best way to sync my rails model with an external database ?

What exactly is your use case for this? It’s hard to give advice on a
question that vague.

Ok. I manage products data in a rails e-commerce but I need sync with
data in an external ERP. I can’t operate on ERP data, they could give me
only some views. I see these views as external db connection in rails,
but I wouldn’t use cron script for checking for change, I would like
have a callback on change made by the ERP. The only solution that I can
see is that the ERP made a call to my app (/product/updated/115) and
then I sync that product.
But if there was possibly made activerecord knowing what the ERP is
doing on the external db…

I can use a callback on my model to update the external table. But in
the other direction, when the external db change some data and would
sync my activerecord model ? I can only think at a REST request of
update of some record. Or a cron sync script, problematic with large db.
There’s better solutions ?

From the little you’ve said, REST sounds like a good solution.

But…why do you need to synchronize at all? Can you just query the
external DB as necessary and avoid duplicating the data?

In general is a typical problem of integration with company resources.
They don’t want give you access direct on db, but they want you work on
sync db.

There’s some better practices, general/typical solution pattern ?

Thanks.

thanks.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

If your app doesn’t really have to do anything with the data
(validate, transform, etc) then I’d try to solve this on the db level.
MySQL replication comes to mind though I’m not sure how that will work
with db views.

Keep us posted on how it goes!

Cheers,
Simon