Thanks to the creator of DBI, I found out that if you install gem based dbi drivers, that the dbi command will not list them, but they will work properly in your ruby code.
So to list tables in our sqlite3 development database.
require 'rubygems'
gem 'dbi'
require 'dbi'
require 'pp'
# Assume dbd-sqlite3 is installed
# sudo gem install dbd-sqlite3
# Assumes we are in our project directory
fromdb = DBI.connect('dbi:SQLite3:db/development.sqlite3', nil, nil)
tables = fromdb.tables
tables.each { |tablename|
pp tablename
}
I tend to use DBI in migrating from foreign environments into a rails app.
I also use DBI to write automatic generators for controllers, models, and
menus. It really makes getting going on a legacy app very fast.
Sunday, February 01, 2009
Mac DBI - dbi binary will not list gem drivers but will work
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment