From e3121a4883a0e916c46f9dd20381840f5b2304c2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 Jul 2014 21:36:21 -0400 Subject: v5 v6: db, minor --- lib/sisu/v5/db_import.rb | 4 +++- lib/sisu/v5/db_select.rb | 24 ++++++++++++++++++------ lib/sisu/v6/db_import.rb | 4 +++- lib/sisu/v6/db_select.rb | 24 ++++++++++++++++++------ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/sisu/v5/db_import.rb b/lib/sisu/v5/db_import.rb index 5feddb92..5819d5c2 100644 --- a/lib/sisu/v5/db_import.rb +++ b/lib/sisu/v5/db_import.rb @@ -91,7 +91,9 @@ module SiSU_DbImport @counter={} @db=SiSU_Env::InfoDb.new if @sql_type==:sqlite - @driver_sqlite3=(@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ + @driver_sqlite3= + (@conn.inspect.match(/^(.{10})/)[1] \ + == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ ? true : false end diff --git a/lib/sisu/v5/db_select.rb b/lib/sisu/v5/db_select.rb index 898dcb71..d52df2bf 100644 --- a/lib/sisu/v5/db_select.rb +++ b/lib/sisu/v5/db_select.rb @@ -79,15 +79,27 @@ module SiSU_DbSelect end def db_exist? 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}"?} + and (not (FileTest.file?(@db.sqlite.db)) \ + or FileTest.zero?(@db.sqlite.db)) + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} exit end if @conn.is_a?(NilClass) - db=@sql_type==:sqlite \ - ? @db.sqlite.db - : @db.psql.db - puts %{no connection with #{@sql_type} database established, createdb "#{db}"?} + db=if @sql_type==:sqlite + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} + @db.sqlite.db + else + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ createdb "#{@db.psql.db}"\n} \ + + %{ after that don't forget to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} + @db.psql.db + end exit end end diff --git a/lib/sisu/v6/db_import.rb b/lib/sisu/v6/db_import.rb index 4331fc2a..4b3fdbc5 100644 --- a/lib/sisu/v6/db_import.rb +++ b/lib/sisu/v6/db_import.rb @@ -91,7 +91,9 @@ module SiSU_DbImport @counter={} @db=SiSU_Env::InfoDb.new if @sql_type==:sqlite - @driver_sqlite3=(@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ + @driver_sqlite3= + (@conn.inspect.match(/^(.{10})/)[1] \ + == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ ? true : false end diff --git a/lib/sisu/v6/db_select.rb b/lib/sisu/v6/db_select.rb index 91d1e37a..e4c00cc0 100644 --- a/lib/sisu/v6/db_select.rb +++ b/lib/sisu/v6/db_select.rb @@ -79,15 +79,27 @@ module SiSU_DbSelect end def db_exist? 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}"?} + and (not (FileTest.file?(@db.sqlite.db)) \ + or FileTest.zero?(@db.sqlite.db)) + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} exit end if @conn.is_a?(NilClass) - db=@sql_type==:sqlite \ - ? @db.sqlite.db - : @db.psql.db - puts %{no connection with #{@sql_type} database established, createdb "#{db}"?} + db=if @sql_type==:sqlite + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} + @db.sqlite.db + else + puts %{no connection with #{@sql_type} database established, you may need to run:\n} \ + + %{ createdb "#{@db.psql.db}"\n} \ + + %{ after that don't forget to run:\n} \ + + %{ sisu --#{@sql_type} --createall\n} \ + + %{ before attempting to populate the database} + @db.psql.db + end exit end end -- cgit v1.2.3