Berkeley DB or Store equivalent?

M

Mk 27

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?
 
M

Mk 27

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)?
 
M

Mk 27

Mk said:
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?
 
M

Mk 27

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.
 
J

James Gray

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 Gray II
 
J

James Gray

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 Gray II
 
M

Mk 27

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

James Edward Gray 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)?
 
J

James Gray

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 Gray II
 
J

Justin Collins

Mk said:
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
 
M

Mk 27

James said:
Multiple libraries, yes. I recommend Amalgalite.

James Edward Gray 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?
 
J

James Gray

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 Gray II
 
M

Mk 27

James said:
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 Gray II

Got ya. Thanks again.
 
M

Mk 27

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.
 
J

James Gray

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 Gray II
 
M

Mike Stephens

Mk said:
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?)
 
B

Brian Candler

Mk said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top