DbAgile – SQL Databases with Agility

DbAgile aims at providing agile tools around databases, and relational/sql databases in particular.

Motivation

Have you ever dreamed of having one central point for keeping your database access infos?


  sh$ dba db:list
  sh$ dba db:use my_contacts

Or displaying a SQL table (say, ‘contacts’) in one shell command?


  sh$ dba sql:show contacts

Or to output the result of any SQL query to yaml, json, csv, ruby, … or even xml?


  sh$ dba bulk:export --yaml "SELECT name, mail FROM contacts" 

Or to have a Restful server on top of SQL databases?


  dba web:tools

Making similar things, … in Ruby?


  DbAgile::dba do |dba|
    # Override environment default values (~/.dbagile, STDOUT)
    dba.repository_path  = ...      # your application database repository
    dba.output_buffer     = ...     # keep output in any IO object
  
    # Start using dbagile commands
    dba.bulk_export %w{--yaml contacts}  # each line pushed in output_buffer
  end

The Rack middleware for the restful server (config.ru):


  #!/usr/bin/env rackup --require dbagile/restful/middleware -p 8711
  app = DbAgile::Restful::Middleware.new{|env|
    #
    # Set the environment!
    #
    # WARNING: Always use ::File instead of File because constants are
    #          resolved in Rack scope, which contains a File class. Not
    #          doing this may mead to bugs in certain ruby versions.
    #
    env.repository_path  = ::File.expand_path('../dbagile', __FILE__)
  }

Pointers

  • DbAgile developper documentation on rdoc.info

Installation


  gem install dbagile (required dependencies are automatically installed)
  dba --help

Required dependencies:

  • sbyc >= 0.1.4
  • sequel >= 3.8.0
  • highline >= 1.5.2

Optional dependencies (according to your needs):

  • mysql, pg, sqlite, … (according to your sql database needs)
  • json (only if you use json import/export)
  • fastercsv (only if you use csv import/export)
  • yaml (only if you use yaml import/export)
  • builder (only if you use xml export)
  • rack >= 1.1.0 (only if you use the restful server)

Credits

DbAgile © 2010 by Bernard Lambeau and the University of Louvain. DbAgile is distributed under the MIT licence. Please see the LICENCE.textile document for details.