# Rails Database Configuration

**URL:** <https://www.ruby-forum.com/t/rails-database-configuration/188808>\
**Category:** Rails\
**Created:** [May 18, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/rails-database-configuration/188808 "2010-05-18T19:32:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [May 18, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/rails-database-configuration/188808/1 "2010-05-18T19:32:26Z")

</div>

I’m building an application in which I’d like groups of users to have  
their  
own dedicated MySQL/SQLite database for the application.

How can I configure Rails so that ActiveRecord uses that group’s  
dedicated  
database from the start?

–

* * *

Joshua S. Martin

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [May 18, 2010, 7:38pm UTC](https://www.ruby-forum.com/t/rails-database-configuration/188808/2 "2010-05-18T19:38:14Z")

</div>

Joshua M. wrote:

> I’m building an application in which I’d like groups of users to have  
> their  
> own dedicated MySQL/SQLite database for the application.
> 
> How can I configure Rails so that ActiveRecord uses that group’s  
> dedicated  
> database from the start?

That question comes up fairly frequently on this list. The usual  
answer: that’s a bad idea – don’t do it. You shouldn’t need to have  
separate databases for groups.

If you can explain more about why you think you want to do this, we can  
offer alternative suggestions.

> –
> 
> * * *
> 
> Joshua S. Martin

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [May 18, 2010, 9:04pm UTC](https://www.ruby-forum.com/t/rails-database-configuration/188808/3 "2010-05-18T21:04:58Z")

</div>

I see. It’s not the fact that I want the data to be separated that made  
me  
consider multiple DBs, it’s the fact that I want the user to be able to  
make  
a full SQL or CSV backup of his account that can be restored from within  
my  
application or into another database.

Perhaps the better question is, how would I make an SQL or CSV export  
(within Rails) of only certain data in the database (the key here being  
only  
certain data) ?

On Tue, May 18, 2010 at 1:38 PM, Marnen Laibow-Koser  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> answer: that’s a bad idea – don’t do it. You shouldn’t need to have
> 
> “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–

* * *

Joshua S. Martin

CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),  
contains information that may be confidential, protected by the attorney  
client or other legal privileges, and or proprietary non public  
information.  
If you are not an intended recipient of this message or an authorized  
assistant to an intended recipient, please notify the sender by replying  
to  
this message and then delete it from your system. Use, dissemination,  
distribution, or reproduction of this message and or any of its  
attachments  
(if any) by unintended recipients is not authorized and may be unlawful.

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [May 18, 2010, 9:28pm UTC](https://www.ruby-forum.com/t/rails-database-configuration/188808/4 "2010-05-18T21:28:34Z")

</div>

Joshua M. wrote:

> I see. It’s not the fact that I want the data to be separated that made  
> me  
> consider multiple DBs, it’s the fact that I want the user to be able to  
> make  
> a full SQL or CSV backup of his account that can be restored from within  
> my  
> application or into another database.
> 
> Perhaps the better question is, how would I make an SQL or CSV export  
> (within Rails) of only certain data in the database (the key here being  
> only  
> certain data) ?

You can easily generate CSV or SQL just like any other view template.

However, for mass SQL backups, I think I’d advise just having Rails call  
the database’s own dump script.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
