aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/dbshell/rails/tasks/dbshell.rake8
-rw-r--r--lib/dbshell/sqlite3_client.rb5
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/dbshell/rails/tasks/dbshell.rake b/lib/dbshell/rails/tasks/dbshell.rake
index 6a74c53..5d19338 100644
--- a/lib/dbshell/rails/tasks/dbshell.rake
+++ b/lib/dbshell/rails/tasks/dbshell.rake
@@ -1,6 +1,8 @@
+require 'dbshell/sqlite3_client'
+
task :dbshell do
# {"default"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000}, "development"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/development.sqlite3"}, "test"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/test.sqlite3"}, "production"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/production.sqlite3"}}
- Rails.application.config.database_configuration
- # system('bash')
- exec('bash')
+ DBShell::Sqlite3Client.runshell(
+ Rails.application.config.database_configuration['development']
+ )
end
diff --git a/lib/dbshell/sqlite3_client.rb b/lib/dbshell/sqlite3_client.rb
index 7e962d7..adc71ef 100644
--- a/lib/dbshell/sqlite3_client.rb
+++ b/lib/dbshell/sqlite3_client.rb
@@ -1,6 +1,11 @@
class DBShell::Sqlite3Client
EXECUTABLE_NAME = 'sqlite3'
+ def self.runshell(db_info)
+ args = self.build_command(db_info)
+ exec(*args)
+ end
+
def self.build_command(db_info)
args = [
EXECUTABLE_NAME,