diff options
Diffstat (limited to 'lib/sisu/v6/dbi.rb')
-rw-r--r-- | lib/sisu/v6/dbi.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/sisu/v6/dbi.rb b/lib/sisu/v6/dbi.rb index acb75e0f..7432f2f3 100644 --- a/lib/sisu/v6/dbi.rb +++ b/lib/sisu/v6/dbi.rb @@ -71,7 +71,6 @@ module SiSU_DBI include SiSU_FormatShared class SQL def initialize(opt) - SiSU_Env::Load.new('dbi',true).prog @opt=opt @db=SiSU_Env::InfoDb.new if @opt.cmd =~/[Dd]/ \ @@ -79,22 +78,25 @@ module SiSU_DBI @sql_type=if @opt.cmd=~/D/ \ or @opt.mod.inspect =~/--pg(?:sql)?/ maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - 'pg' + :pg elsif @opt.cmd =~/d/ \ and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/ maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - 'pg' + :pg elsif @opt.cmd=~/d/ \ or @opt.mod.inspect =~/--(?:sq)?lite/ maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - 'sqlite' + :sqlite elsif @opt.cmd =~/d/ \ and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/ maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - 'sqlite' + :sqlite else maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - 'sqlite' + :sqlite + end + if @sql_type==:pg then SiSU_Env::Load.new('pg',true).prog + elsif @sql_type==:sqlite then SiSU_Env::Load.new('sqlite3',true).prog end end end @@ -105,9 +107,10 @@ module SiSU_DBI end def read_psql begin - @conn=@db.psql.conn_dbi + require 'pg' + @conn=@db.psql.conn_pg rescue - if @opt.mod.inspect=~/--(createall|create)/ + if @opt.mod.inspect=~/--(?:createall|create)/ cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX puts <<-WOK manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet exist @@ -130,8 +133,8 @@ manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet end def connect case @sql_type - when /pg/ then read_psql - when /sqlite/ then read_sqlite + when :pg then read_psql #read_pg + when :sqlite then read_sqlite end SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"DBI (#{@sql_type}) #{@opt.mod}",@opt.fno).dbi_title unless @opt.act[:quiet][:set]==:on begin |