From 7bfd567154b9fd468e5df53901c3d8c383cc25f8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 18 May 2014 08:53:33 -0400 Subject: v5 v6: db, remove ruby-dbi, for: pg ruby-pg, sqlite ruby-sqlite3 (already uses) * ruby-pg require for postgresql * ruby-sqlite3 require for sqlite3 (done previously: already using ruby-sqlite3 rather than ruby-dbi) * ruby-dbi remove calls (in any common files & sisu pg and sisu sqlite3) * separate pg and sqlite db actions --- lib/sisu/v5/db_import.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/sisu/v5/db_import.rb') diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 3d0b7f8c..9e88e7ee 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -109,7 +109,7 @@ module SiSU_DbImport begin @id_n=@driver_sqlite3 \ ? @conn.execute( sql ).join.to_i - : @id_n=@conn.execute( sql ) { |x| x.fetch_all.flatten[0] } + : @id_n=@conn.exec( sql ).getvalue(0,0).to_i @id_n ||=0 rescue puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on @@ -138,7 +138,7 @@ module SiSU_DbImport ;} # note, for .ssm: @md.fns (is set during runtime & is) != @opt.fns @md.opt.fns file_exist=@sql_type==:sqlite \ ? @conn.get_first_value(select_first_match) - : @conn.select_one(select_first_match) + : @conn.exec(select_first_match).field_values("tid")[0] if not file_exist t_d=[] # transaction_data t_d << db_import_metadata @@ -166,11 +166,11 @@ module SiSU_DbImport #@conn.execute("COMMIT") else #'do' works for postgresql - @conn.do("BEGIN") + @conn.exec("BEGIN") t_d.each do |sql| - @conn.do(sql) + @conn.exec(sql) end - @conn.do("COMMIT") + @conn.exec("COMMIT") end rescue DBI::DatabaseError => e STDERR.puts "Error code: #{e.err}" @@ -206,7 +206,7 @@ module SiSU_DbImport else if file_exist @db=SiSU_Env::InfoDb.new - puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} in language code #{cX.blue}#{@opt.lng}#{cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}" + puts "\nfile #{@opt.fns} in language code #{@opt.lng} already exists in database #{@db.psql.db} update instead?" end end end -- cgit v1.2.3