require CNFSQL;
our $CNF = CNFParser->new('apps/sql.cnf');
-my $arguments = $CNF->property(CNFParser::APP_ARGS());
-my $db = CNFSQL::_connectDB(CNFSQL::_credentialsToArray($arguments->{DB_CREDENTIALS}),
- $arguments->{DB_SQL_SOURCE},$arguments->{DB});
our $SQL = $CNF->SQL();
-$SQL->initDatabase($db,1);
-my %schema = $SQL->schema();
+our $db;
+my $arguments = $CNF->property(CNFParser::APP_ARGS());
+try{
+$db = CNFSQL::_connectDB(
+ CNFSQL::_credentialsToArray($arguments->{DB_CREDENTIALS}),
+ $arguments->{DB_SQL_SOURCE},
+ $arguments->{DB}
+ );
+}catch($e){
+ if($e =~ /connection to server at \"(.*)\"/){
+ say `nmap $1` if (-x "/usr/bin/nmap")
+ }
+ die $e
+}
+
+$CNF->log("Connected to DB_SQL_SOURCE -> ".$arguments->{DB_SQL_SOURCE}) if $db;
+$SQL->initDatabase($db,1);
+my %schema = $SQL->schema();
my $action = $arguments->{action};
my $table = $arguments->{table};
die "Config error: Table $table not found in database -> ".$arguments->{DB} if not exists $schema{$table};
our %mig = ();
our @sql = ();
our @statements;
-
+our $die_in_html = 1;
my %schema_tables;
my $isPostgreSQL = 0;
my $TZ;
# By convention any tables and views as appearing in the CNF script should in that order also be created.
tie %tables_create_stmts, "Tie::IxHash";
tie %views, "Tie::IxHash";
+ if(exists $attrs->{parser}->{die_in_html}){
+ $die_in_html = CNFParser::_isTrue($attrs->{parser}->{die_in_html})
+ }
bless $self, $class;
}
try{
return DBI->connect($dsn, $user, $pass, {AutoCommit => 0, RaiseError => 1, PrintError => 0, show_trace=>1});
}catch{
- die "<p>Error->$@</p><br><pre>DSN: $dsn</pre>";
+ die "<p>Error->$@</p><br><pre>DSN: $dsn</pre>" if $die_in_html;
+ die $@
}
}
sub _credentialsToArray{