# Database access from outside rails

**URL:** <https://www.ruby-forum.com/t/database-access-from-outside-rails/55603>\
**Category:** Rails\
**Created:** [March 22, 2006, 11:45am UTC](https://www.ruby-forum.com/t/database-access-from-outside-rails/55603 "2006-03-22T11:45:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 22, 2006, 11:45am UTC](https://www.ruby-forum.com/t/database-access-from-outside-rails/55603/1 "2006-03-22T11:45:19Z")

</div>

I need to have a daemon read from and write to the database, and it  
would be nice to be able to use ActiveRecord and all the model/\* files  
from my rails project rather than doing things the long way. Is there  
any recommended strategy for that?

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 22, 2006, 12:02pm UTC](https://www.ruby-forum.com/t/database-access-from-outside-rails/55603/2 "2006-03-22T12:02:49Z")

</div>

Martin DeMello wrote:

> I need to have a daemon read from and write to the database, and it  
> would be nice to be able to use ActiveRecord and all the model/\* files  
> from my rails project rather than doing things the long way. Is there  
> any recommended strategy for that?  
> script/runner is quite handy for that.

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 22, 2006, 12:03pm UTC](https://www.ruby-forum.com/t/database-access-from-outside-rails/55603/3 "2006-03-22T12:03:47Z")

</div>

search the wiki…

its pretty simple to do…

On Wednesday, March 22, 2006, at 4:14 PM, Martin DeMello wrote:

> I need to have a daemon read from and write to the database, and it  
> would be nice to be able to use ActiveRecord and all the model/\* files  
> from my rails project rather than doing things the long way. Is there  
> any recommended strategy for that?
> 
> martin
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Mikkel B.

www.strongside.dk - Football Portal(DK)  
[nflfeed.helenius.org](http://nflfeed.helenius.org) - Football News(DK)  
ting.minline.dk - Buy Old Stuff!(DK)

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [March 22, 2006, 12:04pm UTC](https://www.ruby-forum.com/t/database-access-from-outside-rails/55603/4 "2006-03-22T12:04:46Z")

</div>

> I need to have a daemon read from and write to the database, and it  
> would be nice to be able to use ActiveRecord and all the model/\* files  
> from my rails project rather than doing things the long way. Is there  
> any recommended strategy for that?

I’ve done something similar. I have a “server” which import some  
information about images which needs some manipulation, then a client  
which reads the db and does the manipulation. The client and server  
are executed from crontab using script/runner:

script/runner ‘require “my\_script.rb”’

This way I don’t have to include the models etc. into the scripts.

regards  
Claus
