Hi Everyone, I have a couple of questions 1. A typical rails environment has 3 databases - development, test, production. - Can I have more? - Is there a limit? 2. In most rails applications you usually have one database type i.e. MySQL or sqlite3 or PostgreSQL or ... - Can I use MySQL and sqlite3 from the same rails application? - Is there a limit? Regards
we can use multiple database in one rails app. here''s the example : database.yml development: adapter: mysql username: root password: database: example_development oracle_development: adapter: oracle username: root password: database: example_oracle_developmen in the model : class User < ActiveRecord::Base establish_connection :oracle_development end class Address < ActiveRecord::Base establish_connection :development end So, based on this code you can have more than 3 database in 1 rails app. That''s my none scientific explanation. thanks. On Mon, Aug 24, 2009 at 8:29 AM, GuruOne <bdhindsa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Everyone, > > I have a couple of questions > 1. A typical rails environment has 3 databases - development, test, > production. > - Can I have more? > - Is there a limit? > > 2. In most rails applications you usually have one database type i.e. > MySQL or sqlite3 or PostgreSQL or ... > - Can I use MySQL and sqlite3 from the same rails application? > - Is there a limit? > > Regards > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
As a usage note, create an abstract base class with the connection you want and inherit the children (models) from this base class for connection pooling to work properly. If you don''t, your database may end up with one connection per model in your code. class OracleConnectBase < ActiveRecord::Base establish_connection :xyz @abstract_class = true end class User < OracleConnectBase # life goes on end Regards, Mukund On Aug 24, 7:04 am, David Angga <carsmetic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> we can use multiple database in one rails app. > here''s the example : > database.yml > development: > > adapter: mysql > username: root > password: > database: example_development > > oracle_development: > adapter: oracle > username: root > > password: > database: example_oracle_developmen > in the model : > class User < ActiveRecord::Base > > establish_connection :oracle_development > end > > class Address < ActiveRecord::Base > > establish_connection :development > end > So, based on this code you can have more than 3 database in 1 rails app. > > That''s my none scientific explanation. > thanks. > > > > On Mon, Aug 24, 2009 at 8:29 AM, GuruOne <bdhin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Everyone, > > > I have a couple of questions > > 1. A typical rails environment has 3 databases - development, test, > > production. > > - Can I have more? > > - Is there a limit? > > > 2. In most rails applications you usually have one database type i.e. > > MySQL or sqlite3 or PostgreSQL or ... > > - Can I use MySQL and sqlite3 from the same rails application? > > - Is there a limit? > > > Regards
On Aug 23, 2009, at 9:29 PM, GuruOne wrote:> > Hi Everyone, > > I have a couple of questions > 1. A typical rails environment has 3 databases - development, test, > production. > - Can I have more? > - Is there a limit?David and Mukund seem to have answered your second question. I''ll focus on this one. I''d rephrase your question a bit: 1. A typical rails application defines three environments - development, test, production. - Can I define others? Yes, you can. I''ve had "staging", "fabrication", and "production_LIVE" environments on various projects in addition to the standard three. - Is there a limit? No, not really. You do have to keep a config/environments/staging.rb (or whatever your environment is called) and the corresponding section of the database.yml file, but that doesn''t put a limit on how many environments you can have. The real limit is probably your ability to give them names that you can keep straight. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > 2. In most rails applications you usually have one database type i.e. > MySQL or sqlite3 or PostgreSQL or ... > - Can I use MySQL and sqlite3 from the same rails application? > - Is there a limit? > > Regards > >
Dear Rob, Thxs. Regards On Aug 24, 9:08 am, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Aug 23, 2009, at 9:29 PM, GuruOne wrote: > > > > > Hi Everyone, > > > I have a couple of questions > > 1. A typicalrailsenvironment has 3 databases - development, test, > > production. > > - Can I have more? > > - Is there a limit? > > David and Mukund seem to have answered your second question. I''ll > focus on this one. > > I''d rephrase your question a bit: > > 1. A typicalrailsapplication defines three environments - > development, test, production. > - Can I define others? > > Yes, you can. I''ve had "staging", "fabrication", and > "production_LIVE" environments on various projects in addition to the > standard three. > > - Is there a limit? > > No, not really. You do have to keep a config/environments/staging.rb > (or whatever your environment is called) and the corresponding section > of thedatabase.yml file, but that doesn''t put a limit on how many > environments you can have. The real limit is probably your ability to > give them names that you can keep straight. > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > > > > > > 2. In mostrailsapplications you usually have onedatabasetype i.e. > > MySQL or sqlite3 or PostgreSQL or ... > > - Can I use MySQL and sqlite3 from the samerailsapplication? > > - Is there a limit? > > > Regards
Thxs. On Aug 23, 9:04 pm, David Angga <carsmetic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> we can use multiple database in one rails app. > here''s the example : > database.yml > development: > > adapter: mysql > username: root > password: > database: example_development > > oracle_development: > adapter: oracle > username: root > > password: > database: example_oracle_developmen > in the model : > class User < ActiveRecord::Base > > establish_connection :oracle_development > end > > class Address < ActiveRecord::Base > > establish_connection :development > end > So, based on this code you can have more than 3 database in 1 rails app. > > That''s my none scientific explanation. > thanks. > > > > On Mon, Aug 24, 2009 at 8:29 AM, GuruOne <bdhin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Everyone, > > > I have a couple of questions > > 1. A typical rails environment has 3 databases - development, test, > > production. > > - Can I have more? > > - Is there a limit? > > > 2. In most rails applications you usually have one database type i.e. > > MySQL or sqlite3 or PostgreSQL or ... > > - Can I use MySQL and sqlite3 from the same rails application? > > - Is there a limit? > > > Regards
Thxs On Aug 24, 6:03 am, Mukund <marut...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> As a usage note, create an abstract base class with the connection you > want and inherit the children (models) from this base class for > connection pooling to work properly. If you don''t, yourdatabasemay > end up with one connection per model in your code. > > class OracleConnectBase < ActiveRecord::Base > establish_connection :xyz > @abstract_class = true > end > > class User < OracleConnectBase > # life goes on > end > > Regards, > Mukund > > On Aug 24, 7:04 am, David Angga <carsmetic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > we can use multipledatabasein onerailsapp. > > here''s the example : > >database.yml > > development: > > > adapter: mysql > > username: root > > password: > > database: example_development > > > oracle_development: > > adapter: oracle > > username: root > > > password: > > database: example_oracle_developmen > > in the model : > > class User < ActiveRecord::Base > > > establish_connection :oracle_development > > end > > > class Address < ActiveRecord::Base > > > establish_connection :development > > end > > So, based on this code you can have more than 3database in 1railsapp. > > > That''s my none scientific explanation. > > thanks. > > > On Mon, Aug 24, 2009 at 8:29 AM, GuruOne <bdhin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Everyone, > > > > I have a couple of questions > > > 1. A typicalrailsenvironment has 3 databases - development, test, > > > production. > > > - Can I have more? > > > - Is there a limit? > > > > 2. In mostrailsapplications you usually have onedatabasetype i.e. > > > MySQL or sqlite3 or PostgreSQL or ... > > > - Can I use MySQL and sqlite3 from the samerailsapplication? > > > - Is there a limit? > > > > Regards