v5 v6: db, --maintenance sql, separated out postgresql & sqlite
authorRalph Amissah <ralph@amissah.com>
Sun, 12 Oct 2014 14:21:03 +0000 (10:21 -0400)
committerRalph Amissah <ralph@amissah.com>
Sun, 12 Oct 2014 14:21:03 +0000 (10:21 -0400)
* could share "maintenance" db import sql file (as done previously), consider

data/doc/sisu/CHANGELOG_v5
data/doc/sisu/CHANGELOG_v6
lib/sisu/v5/db_import.rb
lib/sisu/v5/db_select.rb
lib/sisu/v5/dbi_discrete.rb
lib/sisu/v6/db_import.rb
lib/sisu/v6/db_select.rb
lib/sisu/v6/dbi_discrete.rb

index 7870236dadf2ed39fb2808f76ffb60841be24e66..7f2700bc70b1a3d1877d0bbcc5bb4248407c01a6 100644 (file)
@@ -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
index e5568614f239a6a8a19440ea66b1316485881c2b..ffa7908b2ad5fee62b1aaa47659bf187dfb101e0 100644 (file)
@@ -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
index 0ce248317a89e9132d39984694c979949110ec94..59cff28a5414e3f0fd6ba30839f81af22da5ccb8 100644 (file)
@@ -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 \
index ae87ee1be69d5e4d4efc097f2368aad252b76452..997b6a1ac53b27a8d01766969044ec7419af55d1 100644 (file)
@@ -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)
index 50ef97b4c0c2f047655b322991af3b4bb10bf368..e50f56463eae5a13fa5290f0d080ba730575e023 100644 (file)
@@ -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
index e61290aa116a15e120ddc6926ce2620f6d90afb1..9473863da01e323a0c6d1f1e165a8467e73f06b9 100644 (file)
@@ -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 \
index f7bf7ee0c1c98cd42220af33c41b1f347a210cee..c9c4ffc1d2e340fdcd6a67228762b9d4729e2b56 100644 (file)
@@ -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)
index d4efe6874f6dd1bd4ff8f2832efeb067122436ba..4c3efc46bada45f7db9387c6b2b5285d217d33f8 100644 (file)
@@ -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