Ruby, How Do I Love Thee? Let Me Count the Ways

+1 for sequel

---- Joel VanderWerf <> wrote:


On 11/16/2011 02:58 PM, Aaron D. Gifford wrote:
> I've been looking at Pry to enhance my irb CLI experience and blend a
> bit of shell-like CLI in as well. Is there a database module along
> the lines of Pry I could use to also integrate a MySQL CLI as well?
> I'd love to use Ruby as my system CLI shell and MySQL CLI
> simultaneously... *drool*

Check out sequel[1] -- nice CLI as well as API:

$ sequel sqlite:/
Your database is stored in DB...
>> DB
=> #<Sequel::SQLite::Database: "sqlite:/">
>> mac_array = [1,2,3]
=> [1, 2, 3]
>> DB[:authorized_macs].filter(:device_id => 123).exclude(:mac =>
=> #<Sequel::SQLite::Dataset: "SELECT * FROM `authorized_macs` WHERE
((`device_id` = 123) AND (`mac` NOT IN (1, 2, 3)))">

(works with other dbs besides sqlite, of course; and you can get all
this functionality in irb just by requiring sequel)