From 69d476386d149117ced7c77f9f383646a33bcd38 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 12 Oct 2014 10:21:03 -0400 Subject: v5 v6: db, --maintenance sql, separated out postgresql & sqlite * could share "maintenance" db import sql file (as done previously), consider --- data/doc/sisu/CHANGELOG_v5 | 3 +++ data/doc/sisu/CHANGELOG_v6 | 3 +++ lib/sisu/v5/db_import.rb | 12 +++++++++--- lib/sisu/v5/db_select.rb | 8 ++++++-- lib/sisu/v5/dbi_discrete.rb | 16 ++++++++++++---- lib/sisu/v6/db_import.rb | 12 +++++++++--- lib/sisu/v6/db_select.rb | 8 ++++++-- lib/sisu/v6/dbi_discrete.rb | 16 ++++++++++++---- 8 files changed, 60 insertions(+), 18 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 7870236d..7f2700bc 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -38,6 +38,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.7.0.orig.tar.xz sisu_5.7.0.orig.tar.xz sisu_5.7.0-1.dsc +* db, --maintenance sql, separated out postgresql & sqlite + could share "maintenance" db import sql file (as done previously), consider + * fixes, minor * qrcode, sha call * epub tune, --maintenance related diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index e5568614..ffa7908b 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -28,6 +28,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.3.0.orig.tar.xz sisu_6.3.0.orig.tar.xz sisu_6.3.0-1.dsc +* db, --maintenance sql, separated out postgresql & sqlite + could share "maintenance" db import sql file (as done previously), consider + * fixes, minor * qrcode, sha call * epub tune, --maintenance related diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 0ce24831..59cff28a 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -102,7 +102,9 @@ module SiSU_DbImport ? @conn.execute( sql ).join.to_i : @conn.exec( sql ).getvalue(0,0).to_i rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__}:#{__LINE__}" + end end @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty? sql='SELECT MAX(nid) FROM endnotes' @@ -112,7 +114,9 @@ module SiSU_DbImport : @conn.exec( sql ).getvalue(0,0).to_i @id_n ||=0 rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__}:#{__LINE__}" + end end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv0]=@col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=@col[:lv7]=0 @@ -307,7 +311,9 @@ module SiSU_DbImport : @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 + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__} #{__LINE__}" + end end @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title: if (@opt.act[:verbose][:set]==:on \ diff --git a/lib/sisu/v5/db_select.rb b/lib/sisu/v5/db_select.rb index ae87ee1b..997b6a1a 100644 --- a/lib/sisu/v5/db_select.rb +++ b/lib/sisu/v5/db_select.rb @@ -182,12 +182,16 @@ module SiSU_DbSelect file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + if @sql_type ==:sqlite + File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + else + File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') + end elsif @opt.fns \ and (@opt.act[:sqlite_create][:set] ==:on \ || @opt.act[:psql_create][:set] ==:on) diff --git a/lib/sisu/v5/dbi_discrete.rb b/lib/sisu/v5/dbi_discrete.rb index 50ef97b4..e50f5646 100644 --- a/lib/sisu/v5/dbi_discrete.rb +++ b/lib/sisu/v5/dbi_discrete.rb @@ -81,7 +81,9 @@ module SiSU_DBI_Discrete #% database building @md=@particulars.md if @opt.act[:sqlite][:set]==:on @sql_type=:sqlite - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + maintenance_check(@opt,__FILE__,__LINE__) + end end @output_path=@md.file.output_path.sqlite_discrete.dir @filename=@md.file.base_filename.sqlite_discrete @@ -180,13 +182,19 @@ module SiSU_DBI_Discrete #% database building def populate end def sql_maintenance_file - file=if @opt.inspect =~/M/ + file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" + end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + if @sql_type ==:sqlite + File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + else + File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') + end elsif @opt.fns \ and @opt.fns.inspect =~/create/ nil #sort variations later diff --git a/lib/sisu/v6/db_import.rb b/lib/sisu/v6/db_import.rb index e61290aa..9473863d 100644 --- a/lib/sisu/v6/db_import.rb +++ b/lib/sisu/v6/db_import.rb @@ -102,7 +102,9 @@ module SiSU_DbImport ? @conn.execute( sql ).join.to_i : @conn.exec( sql ).getvalue(0,0).to_i rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__}:#{__LINE__}" + end end @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty? sql='SELECT MAX(nid) FROM endnotes' @@ -112,7 +114,9 @@ module SiSU_DbImport : @conn.exec( sql ).getvalue(0,0).to_i @id_n ||=0 rescue - puts "#{__FILE__}:#{__LINE__}" if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__}:#{__LINE__}" + end end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv0]=@col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=@col[:lv7]=0 @@ -307,7 +311,9 @@ module SiSU_DbImport : @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 + if @opt.act[:maintenance][:set]==:on + puts "#{__FILE__} #{__LINE__}" + end end @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title: if (@opt.act[:verbose][:set]==:on \ diff --git a/lib/sisu/v6/db_select.rb b/lib/sisu/v6/db_select.rb index f7bf7ee0..c9c4ffc1 100644 --- a/lib/sisu/v6/db_select.rb +++ b/lib/sisu/v6/db_select.rb @@ -182,12 +182,16 @@ module SiSU_DbSelect file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + if @sql_type ==:sqlite + File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + else + File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') + end elsif @opt.fns \ and (@opt.act[:sqlite_create][:set] ==:on \ || @opt.act[:psql_create][:set] ==:on) diff --git a/lib/sisu/v6/dbi_discrete.rb b/lib/sisu/v6/dbi_discrete.rb index d4efe687..4c3efc46 100644 --- a/lib/sisu/v6/dbi_discrete.rb +++ b/lib/sisu/v6/dbi_discrete.rb @@ -81,7 +81,9 @@ module SiSU_DBI_Discrete #% database building @md=@particulars.md if @opt.act[:sqlite][:set]==:on @sql_type=:sqlite - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on + if @opt.act[:maintenance][:set]==:on + maintenance_check(@opt,__FILE__,__LINE__) + end end @output_path=@md.file.output_path.sqlite_discrete.dir @filename=@md.file.base_filename.sqlite_discrete @@ -180,13 +182,19 @@ module SiSU_DBI_Discrete #% database building def populate end def sql_maintenance_file - file=if @opt.inspect =~/M/ + file=if @opt.act[:maintenance][:set]==:on if @opt.fns and not @opt.fns.empty? @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on + if @sql_type ==:sqlite + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" + end @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + if @sql_type ==:sqlite + File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + else + File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') + end elsif @opt.fns \ and @opt.fns.inspect =~/create/ nil #sort variations later -- cgit v1.2.3