how to configure rails to use mysql by default (not sqlite3)

Hello,

I am running Mac OS X 10.6.4 and have installed the following:

ruby-1.9.1-p429 (64 bits, I believe!) RubyGems 1.3.7 Rails 2.3.8 MySQL 5.1.49 (64 bits)

I am now getting an error because sqlite3 is not installed and I've read that there are issues installing ruby-sqlite3! SO I'm not sure if I should (or how to) install sqlite3.

A developer suggested I use sqlite3 for testing and mysql for production, but wouldn't that mean having to convert my sqlite database to mysql for production? I might just as well always use mysql, no?

Which leads me to the following question: how do I configure rails to always default to using mysql database instead of sqlite3?

Thank you for your help.

Best regards,

Olivier

just add -d mysql option when you create a new rails project

Olivier Db wrote:

Hello,

I am running Mac OS X 10.6.4 and have installed the following:

ruby-1.9.1-p429 (64 bits, I believe!) RubyGems 1.3.7 Rails 2.3.8 MySQL 5.1.49 (64 bits)

I am now getting an error because sqlite3 is not installed

SQLite comes with Mac OS. The OS uses it internally. No installation should be necessary, though you will probably have to install the sqlite3 gem.

and I've read that there are issues installing ruby-sqlite3!

Not to my knowledge.

SO I'm not sure if I should (or how to) install sqlite3.

A developer suggested I use sqlite3 for testing and mysql for production, but wouldn't that mean having to convert my sqlite database to mysql for production?

No. You have separate databases. You've also got migrations. No conversion is required.

I might just as well always use mysql, no?

It depends. On the one hand, it's extremely convenient and fast to use SQLite for testing and development. On the other hand, you may find that you would rather have the same DB in development as production. I've done it both ways. Both are fine.

(And I would say you might as well *never* use MySQL. PostgreSQL is a much, much better DB.)

Which leads me to the following question: how do I configure rails to always default to using mysql database instead of sqlite3?

-d mysql

Thank you for your help.

Best regards,

Olivier

Best,

Marnen Laibow-Koser wrote:

Olivier Db wrote:

Hello,

I am running Mac OS X 10.6.4 and have installed the following:

ruby-1.9.1-p429 (64 bits, I believe!) RubyGems 1.3.7 Rails 2.3.8 MySQL 5.1.49 (64 bits)

I am now getting an error because sqlite3 is not installed

SQLite comes with Mac OS. The OS uses it internally. No installation should be necessary, though you will probably have to install the sqlite3 gem.

I'm not completely sure, but I don't think SQLite is installed on Mac OS X unless Xcode developer tools are installed. However, many gems need the gcc compiler, which is also not installed until Xcode is installed.

Conclusion... Install Xcode developer tools. The installed comes with Mac OS X.

Robert Walker wrote: [...]

I'm not completely sure, but I don't think SQLite is installed on Mac OS X unless Xcode developer tools are installed.

I don't have a Mac without developer tools handy to check, but I am 99% certain that you are wrong. SQLite is used by the operating system's CoreData component, so it stands to reason that some form of SQLite is bundled into the OS regardless of developer tools.

Best,

Kenneth wrote:

just add -d mysql option when you create a new rails project

when i try to make rails -d mysql example or rails example -d mysql what i do get is to rails apps 1 called mysql and another called example.

Luis Gomez wrote:

Kenneth wrote:

just add -d mysql option when you create a new rails project

when i try to make rails -d mysql example or rails example -d mysql what i do get is to rails apps 1 called mysql and another called example.

ok i know now ... i got to use the -D ( capital letter ) not the -d . -d is for documentations not for databases definition.

Marnen Laibow-Koser wrote:

I don't have a Mac without developer tools handy to check, but I am 99% certain that you are wrong. SQLite is used by the operating system's CoreData component, so it stands to reason that some form of SQLite is bundled into the OS regardless of developer tools.

You're probably right about SQLite, but still the dev tools will likely be needed for compiling sqlite3-ruby native extensions. So whether SQLite is there or not without the dev tools is moot anyway. Still have to install the dev tools to use Rails effectively.

Robert Walker wrote:

Marnen Laibow-Koser wrote:

I don't have a Mac without developer tools handy to check, but I am 99% certain that you are wrong. SQLite is used by the operating system's CoreData component, so it stands to reason that some form of SQLite is bundled into the OS regardless of developer tools.

You're probably right about SQLite, but still the dev tools will likely be needed for compiling sqlite3-ruby native extensions. So whether SQLite is there or not without the dev tools is moot anyway. Still have to install the dev tools to use Rails effectively.

Exactly. (Which is why I don't have a Mac without dev tools handy... :slight_smile: )

Best,