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 | |
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
-rw-r--r-- | data/doc/sisu/CHANGELOG_v5 | 4 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 4 | ||||
-rw-r--r-- | lib/sisu/v5/db_import.rb | 28 | ||||
-rw-r--r-- | lib/sisu/v6/db_import.rb | 28 |
4 files changed, 18 insertions, 46 deletions
diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 217ffed4..ef39e53d 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -44,6 +44,10 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.5.2.orig.tar.xz * options, sisupod parsing fix +* db pg import, fix + * remove dbi from rescue, no longer using ruby-dbi + * ruby-pg query SELECT MAX + %% 5.5.1.orig.tar.xz (2014-07-15:28/2) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_5.5.1 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_5.5.1-1 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index c0be7704..aca7c121 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -34,6 +34,10 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.1.2.orig.tar.xz * options, sisupod parsing fix +* db pg import, fix + * remove dbi from rescue, no longer using ruby-dbi + * ruby-pg query SELECT MAX + %% 6.1.1.orig.tar.xz (2014-07-15:28/2) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_6.1.1 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_6.1.1-1 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 diff --git a/lib/sisu/v6/db_import.rb b/lib/sisu/v6/db_import.rb index 4b3fdbc5..f3e8b96c 100644 --- a/lib/sisu/v6/db_import.rb +++ b/lib/sisu/v6/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 |