Berkeley DB or Store equivalent?

I have never used mySQL because perl’s Storable or BerkeleyDB modules
always did me fine for cgi stuff. I am going to be learning rails, so I
supposed I will have to learn mySQL anyway, but I was wondering: is it
exclusively web based, or could I use it to produce database files for
use in a (non web app) ruby script?

If not, is there a ruby equivalent to something nice and simple like
Storable?

Is there no editing of posts on this forum!??! Tsk.

Looks like SQlite would be better…is there a ruby module for that
(guess I’ll have to go google)?

Mk 27 wrote:

Is there no editing of posts on this forum!??! Tsk.

Looks like SQlite would be better…is there a ruby module for that
(guess I’ll have to go google)?

Okay I see an SQlite::Database, and some associated SQlite/ruby doc that
says “this is not compatible w/ SQlite 3”…is that correct?

Okay I see an SQlite::Database, and some associated SQlite/ruby doc that
says “this is not compatible w/ SQlite 3”…is that correct?

Found sqlite3-ruby in gems.

On May 17, 2009, at 1:01 PM, Mk 27 wrote:

I have never used mySQL because perl’s Storable or BerkeleyDB modules
always did me fine for cgi stuff. I am going to be learning rails,
so I
supposed I will have to learn mySQL anyway, but I was wondering: is it
exclusively web based, or could I use it to produce database files for
use in a (non web app) ruby script?

MySQL is not required for Rails. It works with SQLite, Postgres,
Oracle, and more.

If not, is there a ruby equivalent to something nice and simple like
Storable?

Yeah, Ruby’s Marshal module is similar. If you would prefer a
BerkeleyDB like experience, check out Tokyo Cabinet.

James Edward G. II

On May 17, 2009, at 1:16 PM, Mk 27 wrote:

Looks like SQlite would be better…is there a ruby module for that
(guess I’ll have to go google)?

Multiple libraries, yes. I recommend Amalgalite.

James Edward G. II

James G. wrote:

If not, is there a ruby equivalent to something nice and simple like
Storable?

Yeah, Ruby’s Marshal module is similar. If you would prefer a
BerkeleyDB like experience, check out Tokyo Cabinet.

James Edward G. II

I actually didn’t understand what “SQL” referred to until today (a
specification). That makes it seem a lot more awkward than just saving
a data structure, but I guess I may as well start learning now.

But thanks for “Marshal”, that will probably come in handy. Along the
same lines, is there anything like Data::Dumper (or YAML::XS::Dump)?

On May 17, 2009, at 2:55 PM, Mk 27 wrote:

But thanks for “Marshal”, that will probably come in handy. Along the
same lines, is there anything like Data::Dumper (or YAML::XS::Dump)?

Ruby ships with YAML, yes.

James Edward G. II

Mk 27 wrote:

I have never used mySQL because perl’s Storable or BerkeleyDB modules
always did me fine for cgi stuff. I am going to be learning rails, so I
supposed I will have to learn mySQL anyway, but I was wondering: is it
exclusively web based, or could I use it to produce database files for
use in a (non web app) ruby script?

If not, is there a ruby equivalent to something nice and simple like
Storable?

The standard library comes with dbm, gdbm, sdbm, pstore, and yaml, all
of which can be used as file-based storage. But, as other replies have
pointed out, you probably will not be using them with Rails.

-Justin

James G. wrote:

On May 17, 2009, at 1:16 PM, Mk 27 wrote:

Looks like SQlite would be better…is there a ruby module for that
(guess I’ll have to go google)?

Multiple libraries, yes. I recommend Amalgalite.

James Edward G. II

Glancing at Amalgalite it looks exactly like “SQLite3::Database” (which
I just starting using today). Any other (justified) opinions on this?
Or does it not matter much?

On May 17, 2009, at 6:45 PM, Mk 27 wrote:

Glancing at Amalgalite it looks exactly like
“SQLite3::Database” (which
I just starting using today). Any other (justified) opinions on this?
Or does it not matter much?

Amalgalite embeds SQLite inside of it’s extension and thus does not
rely on an external install. It also activates some new features in
it’s compile that are nice to have.

James Edward G. II

James G. wrote:

On May 17, 2009, at 6:45 PM, Mk 27 wrote:

Glancing at Amalgalite it looks exactly like
“SQLite3::Database” (which
I just starting using today). Any other (justified) opinions on this?
Or does it not matter much?

Amalgalite embeds SQLite inside of it’s extension and thus does not
rely on an external install. It also activates some new features in
it’s compile that are nice to have.

James Edward G. II

Got ya. Thanks again.

On May 17, 2009, at 8:03 PM, Mk 27 wrote:

Here’s a related question: Is is normal to just use sets of 2D tables
with SQL? Or can you create Nth dimensional stuff like a hash of
hashes
of arrays?

In SQL, you use joins to manipulate data in this fashion.

James Edward G. II

Here’s a related question: Is is normal to just use sets of 2D tables
with SQL? Or can you create Nth dimensional stuff like a hash of hashes
of arrays?

I guess it amounts to almost the same thing, implementation wise.

Mk 27 wrote:

Here’s a related question: Is is normal to just use sets of 2D tables
with SQL?

A relational database tends to be organised around relations which are
essentially two dimensional matrices. SQL is also a first order
predicate language which limits what operations you can carry out.

That said, you’re not really using it in the information management
sense, so there’s nothing to stop you storing blobs of any old structure
you like. That works fine as long as you are just using the database as
a sophisticated, scalable filestore, which is probably what you often
are in a Rails context.

(Incidentally why did you choose a Ruby forum rather than a Rails
forum?)

Mk 27 wrote:

I have never used mySQL because perl’s Storable or BerkeleyDB modules
always did me fine for cgi stuff. I am going to be learning rails, so I
supposed I will have to learn mySQL anyway, but I was wondering: is it
exclusively web based, or could I use it to produce database files for
use in a (non web app) ruby script?

I think you’re talking about two independent things.

(1) Data storage for a ruby application. There are a whole bunch of
options for this, SQL and non-SQL, many of which have already been
mentioned. Of the non-SQL alternatives, one of the simplest (written in
Ruby) is Madeleine. One for coolness and speed is CouchDB (you talk to
it via HTTP).

(2) Rails is a web framework, that is, a toolkit for writing web
applications. Quite often these have some sort of data store on the
back, but this is not mandatory.

A default Rails app will be configured to use ActiveRecord to talk to a
sqlite3 SQL database, but you can point it to a different SQL database,
or disable ActiveRecord entirely in config/environment.rb:

config.frameworks -= [:active_record]

and then use whatever non-SQL persistence mechanism you like.

As for whether Rails is “exclusively web based” - no, some of the
components which comprise Rails are useful by themselves - in particular
ActiveRecord. So you can write a non-Rails, non-web application which
still uses ActiveRecord to talk to a SQL database.

There are several other SQL abstraction layers available, but the
advantage of ActiveRecord is that it is a component of Rails, which
means there are lots of excellent books you can buy to make your
learning process easier.

Hope this makes sense!