# Best Database For Ruby

**URL:** <https://www.ruby-forum.com/t/best-database-for-ruby/55955>\
**Category:** Ruby\
**Created:** [March 25, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955 "2006-03-25T23:49:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 25, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/1 "2006-03-25T23:49:02Z")

</div>

I want to learn DB and SQL using Ruby

Project is not too big. Probably need 30 tables

Everyone at work tells me MySQL is the best… I used to use Informix a  
long  
time ago. It doesn’t look like I can get this for linux.

thanks in advance.

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 25, 2006, 11:54pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/2 "2006-03-25T23:54:04Z")

</div>

Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix a long  
> time ago. It doesn’t look like I can get this for linux.
> 
> thanks in advance.

As always, it depends on what you want to do. Postgres might be an  
alternative - especially since it has proper transaction support, stored  
procedures etc. significantly longer than MySQL.

Kind regards

```
robert
```

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 12:27am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/3 "2006-03-26T00:27:07Z")

</div>

On Mar 25, 2006, at 11:48 PM, Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use  
> Informix a long  
> time ago. It doesn’t look like I can get this for linux.

I suggest using [http://ruby-dbi.rubyforge.org](http://ruby-dbi.rubyforge.org) to help keep your code  
database-independent.

– Daniel

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 12:52am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/4 "2006-03-26T00:52:59Z")

</div>

2006/3/25, Butternut squash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix a long  
> time ago. It doesn’t look like I can get this for linux.

You can download Informix for Linux from here:  
[http://www14.software.ibm.com/webapp/download/search.jsp?go=y&rs=ifxsee](http://www14.software.ibm.com/webapp/download/search.jsp?go=y&rs=ifxsee)

and use it with Ruby with this:  
[http://ruby-informix.rubyforge.org](http://ruby-informix.rubyforge.org)

I’m running Informix on Solaris and Fedora Core 4 without any problem.

I’ve found Informix very nice.

> thanks in advance.

–  
Gerardo S.  
“Between individuals, as between nations, respect for the rights of  
others is peace” - Don Benito Juárez

> **[Santana's Tech Notes](http://santanatechnotes.blogspot.com/)**
>
> Small notes about technical related stuff I do, mainly OpenBSD and Ruby

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 4:11am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/5 "2006-03-26T04:11:38Z")

</div>

On 3/25/06, Reid T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> property :author, String
> 
> c.save  
> }  
> puts Time.now

I’ve never used og, but I suspect that’d drop to \< 10s if you wrapped  
it all in a transaction.

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 1:03am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/6 "2006-03-26T01:03:14Z")

</div>

Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix a long  
> time ago. It doesn’t look like I can get this for linux.
> 
> thanks in advance.

PostgreSQL [www.postgresql.org](http://www.postgresql.org)

#for ruby db interaction…  
gem install postgres  
gem install postgres-pr

# [http://nitrohq.com](http://nitrohq.com)[HugeDomains.com](http://www.nitrohq.com/view/Og)

gem install nitro -y

PostgreSQL and Og work very well…

simple example – playing around with ruby and postgresql on win XP…  
10000 inserts in ~54 seconds ( pentium 4, 2+ghz, 1GB ram )

## ogtest.rb

require ‘og’

class Comment  
property :title, String  
property :body, String  
property :author, String  
property :create\_time, Time  
end

og\_psql = {  
:destroy =\> false,  
:store =\> :psql,  
:user =\> ‘rthompso’,  
:password =\> ‘rthompso’,  
:name =\> ‘testog’  
}

Og.setup(og\_psql)

puts Time.now

# save the object in the database

1.upto(10000) { |i|  
c = Comment.new  
c.title = ‘Hello’  
c.body = ‘World’  
c.create\_time = Time.now  
c.author = ‘tml’  
c.save  
}  
puts Time.now

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 6:48am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/7 "2006-03-26T06:48:02Z")

</div>

Reid T. wrote:

> > > > Project is not too big. Probably need 30 tables  
> > > > PostgreSQL [www.postgresql.org](http://www.postgresql.org)  
> > > > I think the debate between Postgres and MySQL is about as inflammatory  
> > > > as vi and  
> > > > emacs. However I’m of the opinion that Postgres is ultimately a better  
> > > > database  
> > > > if you are going to do real database things where the data is changing  
> > > > frequently (INSERT, UPDATE, DELETE) as opposed to just reading it.

But I haven’t any hard metric data to support any of this.

Unless there’s something specifically ruby-esque to make the advantage  
clearer.

Postgres is nicely object oriented if you are into that sort of thing.

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 6:36am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/8 "2006-03-26T06:36:29Z")

</div>

Pat M. wrote:

> > > 
> > 
> > gem install nitro -y
> > 
> > :user =\> ‘rthompso’,  
> > c.title = ‘Hello’
> 
> I’ve never used og, but I suspect that’d drop to \< 10s if you wrapped  
> it all in a transaction.

yep - was just meant to show a simple usage with stats… but, since i’m  
interested anyway…

Different machine - athlon 2500, 512MB RAM, windows XP – postgresql  
8.0.3 rather than PostgreSQL 8.1.3 and running ruby from cygwin rather  
than natively…

Runs in 12-13 seconds – entirely possible that the other box( p4,  
2+ghz, 1GB ram, native ruby ) could drop it down under 10 seconds( or  
even this box, if I took cygwin out of the equation ).

db =Og.setup(og\_psql)  
t1= Time.now  
db.store.start

1.upto(10000) { |i|  
c = Comment.new  
c.title = ‘Hello’  
c.body = ‘World’  
c.create\_time = Time.now  
c.author = ‘tml’  
c.save  
}

db.store.commit  
puts Time.now - t1

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 7:05am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/9 "2006-03-26T07:05:38Z")

</div>

On Sun, 26 Mar 2006, Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix a long  
> time ago. It doesn’t look like I can get this for linux.
> 
> thanks in advance.

if your applications really need network connectivity the consider mysql  
or  
postrgresql - if they do not it’s madness not to use sqlite, which has  
great  
ruby support.

regards.

-a

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 6:49am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/10 "2006-03-26T06:49:10Z")

</div>

Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix a long  
> time ago. It doesn’t look like I can get this for linux.

Alot of folks have already mentioned Postgresql. I hear there is iffy  
blob support if you use it  
with ActiveRecord (and the rest of Rails). I can’t say for Nitro/Og.

I use Mysql without any issue. It has served me well at work, at home  
and on the side.

Zach

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 7:38am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/11 "2006-03-26T07:38:54Z")

</div>

Reid T. wrote:

> > > > Informix a long  
> > > > gem install postgres-pr
> > > 
> > > * * *
> > > 
> > > :destroy =\> false,  
> > > 1.upto(10000) { |i|
> 
> Different machine - athlon 2500, 512MB RAM, windows XP – postgresql
> 
> puts Time.now - t1

Upated athlon system to PostgreSQL 8.1.3  
8.78-9.2 seconds…

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 7:58am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/12 "2006-03-26T07:58:47Z")

</div>

removed\_email\_address@domain.invalid wrote:

> On Sun, 26 Mar 2006, Butternut squash wrote:
> 
> > I want to learn DB and SQL using Ruby  
> > …

> if your applications really need network connectivity the consider mysql or  
> postrgresql - if they do not it’s madness not to use sqlite, which has  
> great  
> ruby support.

But will using sqlite help one trying to learn SQL?

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 8:21am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/13 "2006-03-26T08:21:06Z")

</div>

On Sun, 26 Mar 2006, James B. wrote:

> > if your applications really need network connectivity the consider mysql or  
> > postrgresql - if they do not it’s madness not to use sqlite, which has  
> > great ruby support.
> 
> But will using sqlite help one trying to learn SQL?

no one can help someone using sql, we can only watch in dismay and  
horror 😉

seriously though - why not? all the bloody dbs have there own dialect -  
might  
as well commit to either learning to learn them or to not and using dbi

- in  
either case sqlite fits in.

besides - i think a good hacker could learn the entire sqlite dialect in  
the  
time it takes to install mysql and get authentication and networking  
running  
properly. especially once we throw user ‘www’ into the mix 😉

regards.

-a

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 8:28am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/14 "2006-03-26T08:28:36Z")

</div>

On 3/26/06, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > postrgresql - if they do not it’s madness not to use sqlite, which has  
> > [http://www.30secondrule.com](http://www.30secondrule.com) - Building Better Tools
> 
> SQLite ([http://www.sqlite.org](http://www.sqlite.org)) has good SQL92 support (execeptions are  
> [SQL Features That SQLite Does Not Implement](http://www.sqlite.org/omitted.html)). I use sqlite frequently and I was  
> always amazed of its ease to use. As stated above there is no need to  
> look  
> at MySQL or Postgre unless you really need their features - network  
> support  
> comming into mind. They are great products, do not get me wrong, but  
> they  
> are very probably much more than you need.  
> Now when it comes to learning you might use all of them and more of  
> course (  
> e.g. Firebird which seeems quite nice too and has pretty good ANSI-SQL  
> support. [http://firebird.sourceforge.net/](http://firebird.sourceforge.net/))

Hope you find that helpfull.  
Robert

–  
Deux choses sont infinies : l’univers et la bÃªtise humaine ; en ce qui  
concerne l’univers, je n’en ai pas acquis la certitude absolue.

- Albert Einstein

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 12:50pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/15 "2006-03-26T12:50:09Z")

</div>

Reid T.:

> > c.title = ‘Hello’
> 
> Upated athlon system to PostgreSQL 8.1.3  
> 8.78-9.2 seconds…

As Ara said: “it’s madness not to use sqlite” if you don’t need the  
networking capabilities of MySQL or whatever.

change DB to sqlite3:

* * *

require ‘sqlite3’

File.delete(“test.db”) if File.exists?(“test.db”)  
db = SQLite3::Database.new(“test.db”)  
t1= Time.now

db.execute(“CREATE TABLE comments (title, body, create\_time, author)”)

db.transaction do  
1.upto(10000) do  
db.execute(“insert into comments values (‘Hello’, ‘World’, ?, ‘tml’  
)”, Time.now)  
end  
end

## puts Time.now - t1

1.5 seconds

(Pentium M, 2.13GHz, 1GB RAM)

cheers

Simon

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 26, 2006, 3:28pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/16 "2006-03-26T15:28:29Z")

</div>

Tom A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> I think the debate between Postgres and MySQL is about as inflammatory  
> as vi and emacs.

Of course, the difference is that _both_ vi and emacs are very good  
editors…  
_scnr_

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 27, 2006, 6:41pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/17 "2006-03-27T18:41:49Z")

</div>

Tom A. wrote:

> Postgres is nicely object oriented if you are into that sort of thing.

Now, I don’t want to veer way off topic for either this thread or this  
list, but I was wondering what brings you to say that? I’ve never  
thought of any particular DB being more or less OO.

Recently, I investigated Postgres’ table inheritance feature, but found  
it to be lacking in robustness. Constraints are not carried over to  
child tables, and even if you redeclare them in child table definitions,  
UNIQUE constraints are not enforced across the rows of both tables  
(i.e., you can have a row with table1.id = 1 and a row with table2.id =  
1).

To me, this makes it (inheritance, not Postgres as a whole) seem okay  
for toy applications, but not for anything serious.

(For the record, I prefer Postgres, but only because at the time I made  
my choice, MySQL was lacking in “serious” DB features.)

/me leaves it at that, not wanting to argue PG vs. MySQL

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 27, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/18 "2006-03-27T20:13:11Z")

</div>

Being someone who has done a fair amount of development on Og, I can  
tell you that this isn’t just the database performance, the sqlite  
adapter is leaner than the others since the project lead uses it and  
the others definitely need a lot of optimization.

I can also tell you that having watched insert performance postgresql  
vs sqlite that postgresql usually beat it heavily on my machine, but  
my machine was slower than yours.

On 27 Mar 2006, at 18:23, Reid T. wrote:

> > > > t1= Time.now
> > 
> > As Ara said: “it’s madness not to use sqlite” if you don’t need the
> 
> agreed, if sqlite meets your needs, it would be the tool to use.  
> IMO it is an exceptional piece of software for what it is designed  
> to do.

Rob Pitt  
Technical Architect

Motionpath Digital Media Ltd.  
St Georges Road, Brighton, BN2 1ED.  
Office: 01273 608708

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 28, 2006, 4:34am UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/19 "2006-03-28T04:34:09Z")

</div>

On Mar 25, 2006, at 14:48, Butternut squash wrote:

> I want to learn DB and SQL using Ruby
> 
> Project is not too big. Probably need 30 tables
> 
> Everyone at work tells me MySQL is the best… I used to use Informix  
> a long  
> time ago. It doesn’t look like I can get this for linux.

Well, apparently you can, according to somebody else’s post. However,  
if that still doesn’t appear to be a good choice, I’d also have to  
recommend PostgreSQL over MySQL. I learned SQL on Microsoft SQLServer  
6.5, and PostgreSQL generally acted a lot more like what I was  
expecting than MySQL could. MySQL has grown a lot since I checked them  
both out, but so has Postgres, and I still find Postgres’s behavior to  
be closer to what I’ve come to expect out of a “real” SQL relational  
database. It’s more paranoid about data integrity, for one thing, and  
is willing to let me enforce very strict measures indeed.

The biggest nuisance is that outer joins use a very different syntax  
than what I’m used to. {shrug}

---

<div class="post-metadata">

**Author:** ![Butternut\_squash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@Butternut\_squash](https://www.ruby-forum.com/u/Butternut_squash)\
**Post date:** [March 27, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/best-database-for-ruby/55955/20 "2006-03-27T19:23:58Z")

</div>

Simon Kröger wrote:

> > > puts Time.now - t1
> 
> (Pentium M, 2.13GHz, 1GB RAM)
> 
> cheers
> 
> Simon

agreed, if sqlite meets your needs, it would be the tool to use. IMO it  
is an exceptional piece of software for what it is designed to do.
