diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-07-22 21:37:35 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-07-22 21:37:35 -0400 |
commit | 94aa1549826bb5e7ad17045625f27be7db8cdcaa (patch) | |
tree | d0d5267b19207fa8ac58ee5138eb7b86fac5d539 /lib/sisu/v5 | |
parent | v5 v6: db, minor (diff) |
v5 v6: db, pg import, fix
* remove dbi from rescue, no longer using ruby-dbi
* ruby-pg query SELECT MAX
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r-- | lib/sisu/v5/db_import.rb | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 5819d5c2..3e9d19ec 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -102,7 +102,7 @@ module SiSU_DbImport @col[:lid] ||=0 @col[:lid]=@driver_sqlite3 \ ? @conn.execute( sql ).join.to_i - : @conn.execute( sql ) { |x| x.fetch_all.flatten[0] } + : @conn.exec( sql ).getvalue(0,0).to_i rescue puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on end @@ -111,7 +111,7 @@ module SiSU_DbImport begin @id_n=@driver_sqlite3 \ ? @conn.execute( sql ).join.to_i - : @id_n=@conn.exec( sql ).getvalue(0,0).to_i + : @conn.exec( sql ).getvalue(0,0).to_i @id_n ||=0 rescue puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on @@ -181,22 +181,6 @@ module SiSU_DbImport end @conn.exec("COMMIT") end - rescue DBI::DatabaseError => e - STDERR.puts "Error code: #{e.err}" - STDERR.puts "Error message: #{e.errstr}" - STDERR.puts "Error SQLSTATE: #{e.state}" - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" - sql=File.new(sqlfn,'w') - t_d.each {|i| sql.puts i} - p sqlfn - if @opt.act[:maintenance][:set]==:on - puts sql - p @conn.methods.sort - puts "#{__FILE__}:#{__LINE__}" - end rescue SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -270,11 +254,9 @@ module SiSU_DbImport sql='SELECT MAX(tid) FROM metadata_and_text;' begin @@id_t ||=0 - id_t=if @driver_sqlite3 - @conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i } - else - @conn.execute( sql ) { |x| x.fetch_all.flatten[0] } - end + id_t=@driver_sqlite3 \ + ? @conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i } + : @conn.exec( sql ).getvalue(0,0).to_i @@id_t=id_t if id_t rescue puts "#{__FILE__} #{__LINE__}" if @opt.act[:maintenance][:set]==:on |