aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/db_select.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-05-18 08:49:03 -0400
committerRalph Amissah <ralph@amissah.com>2014-05-18 08:49:03 -0400
commit307ecb4df591aa675b71839014debf6e81d462e1 (patch)
tree647e6738bc5868f09c62e07cc03c45ab64e3c1cd /lib/sisu/v6/db_select.rb
parentv6: utils, add ok code marker (diff)
v5 v6: db, use symbols to identify sql engine
Diffstat (limited to 'lib/sisu/v6/db_select.rb')
-rw-r--r--lib/sisu/v6/db_select.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/sisu/v6/db_select.rb b/lib/sisu/v6/db_select.rb
index 56b424d7..9a2c2eb0 100644
--- a/lib/sisu/v6/db_select.rb
+++ b/lib/sisu/v6/db_select.rb
@@ -63,7 +63,7 @@
=end
module SiSU_DbSelect
class Case
- def initialize(opt,conn='',sql_type='pg')
+ def initialize(opt,conn='',sql_type=:pg)
@opt,@conn,@sql_type=opt,conn,sql_type
@db=SiSU_Env::InfoDb.new
@file_maint=sql_maintenance_file
@@ -78,13 +78,13 @@ module SiSU_DbSelect
end
end
def db_exist?
- if @sql_type=='sqlite' \
+ if @sql_type==:sqlite \
and (not (FileTest.file?(@db.sqlite.db)) or FileTest.zero?(@db.sqlite.db))
puts %{no connection with #{@sql_type} database established, createdb "#{@db.sqlite.db}"?}
exit
end
if @conn.is_a?(NilClass)
- db=@sql_type=='sqlite' \
+ db=@sql_type==:sqlite \
? @db.sqlite.db
: @db.psql.db
puts %{no connection with #{@sql_type} database established, createdb "#{db}"?}
@@ -95,7 +95,7 @@ module SiSU_DbSelect
file=if @opt.inspect =~/M/
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
+ puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type ==:sqlite and @opt.act[:maintenance][:set]==:on
@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+')
@@ -173,8 +173,8 @@ module SiSU_DbSelect
db_exist?
@sdb_import.marshal_load
tell=case @sql_type
- when /sqlite/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?")
- when /pg/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?")
+ when :sqlite then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?")
+ when :pg then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?")
else '???'
end
tell.puts_grey if @opt.act[:verbose][:set]==:on
@@ -183,8 +183,8 @@ module SiSU_DbSelect
@sdb_remove_doc.remove
@sdb_import.marshal_load
tell=case @sql_type
- when /sqlite/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?")
- when /pg/ then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?")
+ when :sqlite then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"sqlite3 #{@db.sqlite.db} database?")
+ when :pg then SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],"pgaccess or psql #{@db.psql.db} database?")
else '???'
end
tell.puts_grey if @opt.act[:verbose][:set]==:on