views:

343

answers:

3

I have no idea how I would set up a BerkelyDB database in a Ruby or Rails project.

Does anyone have any experience configuring one, that they could talk about?

Maybe using ActiveRecord or Datamapper?

A: 

i think you can use MySQL and use the BerkeleyDB storage engine and use ActiveRecord or DataMapper as usual. Will be cool to use BDB that way. try this: http://dev.mysql.com/doc/refman/5.0/en/bdb-storage-engine.html

auvi
A: 

You can't use it with ActiveRecord or DataMapper (unless you're using MySQL with BerkeleyDB as the storage engine, as auvi said), but you can use the BDB library. Here is some basic example code.

I don't know if there's a specific reason you need BerkeleyDB, but chances are that you don't. Unless all you need is to store one big huge hash table, I'd stick to SQLite or, even better, MySQL or PostgreSQL. Berkeley doesn't give you any relational functionality such as joins, so you have to write those yourself (not to mention the API is kind of messy).

musicfreak
Downvoted because Sql databases don't automatically equal "better", which is a highly subjective term anyway. There are loads of reasons why someone or a company might choose BDB and just hand-waving a BS answer like "just use a sql database" id too dismissive of the OP's question. Also downvoted because "get" and "put" are about as simple and elegant as APIs can come...
Shaun
@Shaun: I gave a legitimate answer, and then I stated that it *may* not be necessary to use BDB, considering the OP wants to use it with ActiveRecord. I don't know the OP's specific situation, and if he has a perfectly valid reason to use BDB, more power to him. However, most of the time, people try to use a non-relational database just for the sake of being different, which I don't think makes any sense. Either way, I don't know why I got a downvote because I did answer his question in the first part of my answer.
musicfreak
+2  A: 

I would use Moneta: http://github.com/wycats/moneta/tree/master

BJ Clark
Me too. That's great. Thanks. Btw, I'd like to persist an entity, in case you have any ideas: http://stackoverflow.com/questions/992173/how-would-you-represent-a-relational-entity-as-a-single-unit-of-retrievable-data/992223#992223
Hank