Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Best gem for an existing mysql database

Reply
Thread Tools

Best gem for an existing mysql database

 
 
Iain Barnett
Guest
Posts: n/a
 
      04-28-2011
Hi,

I've an existing MySql database, and not having used any of the major =
database gems like ActiveRecord, Sequel etc etc I was wondering which =
one would work well against an already built DB ?

The quicker I can get up and running the better. It would also be nice =
if I could bypass whatever sugar it has to run SQL directly, so I can =
just plug in any exising queries that are lying around.


Any help on this is much appreciated.

Regards,
Iain=

 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      04-28-2011
On 04/28/2011 05:24 AM, Iain Barnett wrote:
> Hi,
>
> I've an existing MySql database, and not having used any of the major database gems like ActiveRecord, Sequel etc etc I was wondering which one would work well against an already built DB ?
>
> The quicker I can get up and running the better. It would also be nice if I could bypass whatever sugar it has to run SQL directly, so I can just plug in any exising queries that are lying around.


Sequel and AR will both let you drop to the SQL level, if the model
level isn't quite right for what you want to do. I don't know about
DataMapper or other ORMs.

One thing I've always liked about sequel is that there is an
intermediate level, between models and SQL: datasets with their chained
query methods. Some examples:

http://cheat.errtheblog.com/s/sequel

The documentation for datasets:

http://sequel.rubyforge.org/rdoc/fil...sics_rdoc.html

Rather than use models, I often find it easier to think in relational
terms and code in ruby, and that's what sequel's datasets let you do.

Another factor to consider, when the database precedes the app, is
whether the ORM layer supports the schema. IIUC, AR doesn't support
composite primary keys without using an extra library. Sequel does
support composite primary keys (this was very helpful to my team just in
the last few weeks). This difference may not matter much, but it's
something to be aware of.

More on sequel's differences from AR:

http://sequel.rubyforge.org/rdoc/fil...cord_rdoc.html

 
Reply With Quote
 
 
 
 
Iain Barnett
Guest
Posts: n/a
 
      04-28-2011

On 28 Apr 2011, at 20:42, Joel VanderWerf wrote:
>=20
> Another factor to consider, when the database precedes the app, is =

whether the ORM layer supports the schema. IIUC, AR doesn't support =
composite primary keys without using an extra library. Sequel does =
support composite primary keys (this was very helpful to my team just in =
the last few weeks). This difference may not matter much, but it's =
something to be aware of.

This is a deal breaker, or maker in this case as the database does hold =
several composite keys.

>=20
> Rather than use models, I often find it easier to think in relational =

terms and code in ruby, and that's what sequel's datasets let you do.

I think this would suit my style of thinking too. I'm quite comfortable =
with SQL and sets and they seem to make more sense for a lot of problems =
than starting with objects, for me anyway.

>=20
> Sequel and AR will both let you drop to the SQL level, if the model =

level isn't quite right for what you want to do. I don't know about =
DataMapper or other ORMs.
>=20
> One thing I've always liked about sequel is that there is an =

intermediate level, between models and SQL: datasets with their chained =
query methods. Some examples:
>=20
> http://cheat.errtheblog.com/s/sequel
>=20
> The documentation for datasets:
>=20
> http://sequel.rubyforge.org/rdoc/fil...sics_rdoc.html
>=20
>=20
> More on sequel's differences from AR:
>=20
> http://sequel.rubyforge.org/rdoc/fil...cord_rdoc.html


Thanks, I'll give those a look. I really appreciate the time you've =
taken to give me a good answer, it's difficult to tell from just reading =
the docs / looking at examples, as they all *seem* to do what you want, =
and right now I don't have the time to get far down the road before =
failing.

Thanks again.

Regards,
Iain=

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing mysql gem on Win7 x64 for MySQL 5.1.x Geoff Rowell Ruby 5 08-03-2010 06:07 PM
feezing mysql gem + unitiliazed constant MysqlCompat::Mysql Renato Jf Ruby 3 12-15-2009 12:13 AM
mySQL Ruby Gem and MAMP mySQL Mark Meijer Ruby 3 02-03-2008 04:19 AM
RubyGems 0.9.1 calling a gem with gem '<gem>' Austin 7873 Ruby 5 01-27-2007 10:05 PM
MySQL Bindings, Pather Server, existing MySQL - help Brian Ablaza Ruby 1 02-27-2006 08:32 PM



Advertisments