# Inserting records using REST

**URL:** <https://www.ruby-forum.com/t/inserting-records-using-rest/178541>\
**Category:** Rails\
**Created:** [November 6, 2009, 6:36am UTC](https://www.ruby-forum.com/t/inserting-records-using-rest/178541 "2009-11-06T06:36:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [November 6, 2009, 6:36am UTC](https://www.ruby-forum.com/t/inserting-records-using-rest/178541/1 "2009-11-06T06:36:20Z")

</div>

HI All,

I have a situation to insert records from table of one database to a  
table of another database. Previously I did it using the following code  
in the script.

establish\_connection File.open( “#{RAILS\_ROOT}/config/database.yml” )

and change the settings of database.yml to connect to the database  
present in a **remote server**.

But the problem here is, now a firewall is been setup in the remote  
server and am not able to connect to the remote database using  
database.yml.

Please suggest me an alternative to do this.

thanks,  
Raju

---

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [November 6, 2009, 9:44am UTC](https://www.ruby-forum.com/t/inserting-records-using-rest/178541/2 "2009-11-06T09:44:44Z")

</div>

On Fri, Nov 6, 2009 at 6:36 AM, Raju A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> present in a **remote server**.
> 
> But the problem here is, now a firewall is been setup in the remote  
> server and am not able to connect to the remote database using  
> database.yml.
> 
> Please suggest me an alternative to do this.

What are the alternatives? I mean we know the port for the database  
was closed, but is there a live application on that server that access  
that database? can you install a new application there? can you run a  
rake task there?

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [November 6, 2009, 12:28pm UTC](https://www.ruby-forum.com/t/inserting-records-using-rest/178541/3 "2009-11-06T12:28:22Z")

</div>

Thanks for your reply Leonardo,

There is a live application in that server. I am using Web services with  
REST, Still in the process,

I am using RestClient.get for requesting xml and Hash.from\_xml to parse  
the xml string.

Thanks,  
Raju

---

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [November 6, 2009, 1:53pm UTC](https://www.ruby-forum.com/t/inserting-records-using-rest/178541/4 "2009-11-06T13:53:29Z")

</div>

On Fri, Nov 6, 2009 at 12:28 PM, Raju A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for your reply Leonardo,
> 
> There is a live application in that server. I am using Web services with  
> REST, Still in the process,
> 
> I am using RestClient.get for requesting xml and Hash.from\_xml to parse  
> the xml string.

I would use that application to create the new records. If you can  
modify the application that will receive the data, you can add some  
service to receive a batch of records so you don’t have to add them  
one by one wich will be noticeably slower.

–  
Leonardo M…  
There’s no place like ~
