Forum: Ruby Berkeley DB or Store equivalent?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-17 20:01
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?
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-17 20:16
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)?
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-17 20:21
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?
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-17 21:08
> 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.
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2009-05-17 21:49
(Received via mailing list)
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 Gray II
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2009-05-17 21:50
(Received via mailing list)
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 Gray II
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-17 21:55
James Gray 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 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)?
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2009-05-17 22:18
(Received via mailing list)
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 Gray II
6e366eb5a71be2bad7f383d42aeb4788?d=identicon&s=25 Justin Collins (Guest)
on 2009-05-17 22:37
(Received via mailing list)
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
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-18 01:45
James Gray 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 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?
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2009-05-18 01:59
(Received via mailing list)
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 Gray II
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-18 03:00
James Gray 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 Gray II

Got ya.  Thanks again.
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-18 03:03
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.
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2009-05-18 05:12
(Received via mailing list)
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 Gray II
D1309ef77561e3cdf0ddcab60b244e52?d=identicon&s=25 Mike Stephens (aspirer)
on 2009-05-18 10:41
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?)
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-05-19 16:04
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!
This topic is locked and can not be replied to.