aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/db_import.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-05-18 08:53:33 -0400
committerRalph Amissah <ralph@amissah.com>2014-05-18 08:53:36 -0400
commit7bfd567154b9fd468e5df53901c3d8c383cc25f8 (patch)
tree9967a2bc8fa8880193285f2dd52d77186bdb072d /lib/sisu/v6/db_import.rb
parentv5 v6: db, use symbols to identify sql engine (diff)
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
Diffstat (limited to 'lib/sisu/v6/db_import.rb')
-rw-r--r--lib/sisu/v6/db_import.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sisu/v6/db_import.rb b/lib/sisu/v6/db_import.rb
index dd9dfe84..35fb631a 100644
--- a/lib/sisu/v6/db_import.rb
+++ b/lib/sisu/v6/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