mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
contrib/configdb: for debugging
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15011 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
415a437296
commit
0513e5535f
@ -179,8 +179,7 @@ sub _cfgDB_Reorg(;$$);
|
|||||||
sub _cfgDB_Rotate($$);
|
sub _cfgDB_Rotate($$);
|
||||||
sub _cfgDB_Search($$;$);
|
sub _cfgDB_Search($$;$);
|
||||||
sub _cfgDB_Uuid();
|
sub _cfgDB_Uuid();
|
||||||
sub _cfgDB_table_exists($$) {
|
sub _cfgDB_table_exists($$);
|
||||||
|
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Read configuration file for DB connection
|
# Read configuration file for DB connection
|
||||||
@ -301,20 +300,16 @@ sub cfgDB_Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
### migrate fhembinfilesave to fhemb64filesave
|
### migrate fhembinfilesave to fhemb64filesave
|
||||||
# check: fhembinfilesave exists?
|
# # check: fhembinfilesave exists?
|
||||||
# my $sth_test = $fhem_dbh->table_info(undef, 'public', "fhembinfilesave", 'TABLE');
|
# my $sth_test = $fhem_dbh->table_info(undef, 'public', "fhembinfilesave", 'TABLE');
|
||||||
# $sth_test->execute;
|
# $sth_test->execute;
|
||||||
# my @info = $sth_test->fetchrow_array;
|
# my @info = $sth_test->fetchrow_array;
|
||||||
# my $exists = scalar @info;
|
# my $exists = scalar @info;
|
||||||
# printf "exists: $exists\n";
|
if (_cfgDB_table_exists($fhem_dbh,'fhembinfilesave')) {
|
||||||
# if ($exists) {
|
|
||||||
|
|
||||||
if ( _cfgDB_table_exists($fhem_dbh,"fhembinfilesave") ) {
|
|
||||||
# $sth_test->finish();
|
# $sth_test->finish();
|
||||||
# check: any files for migratione?
|
# check: any files for migratione?
|
||||||
$count = undef;
|
$count = undef;
|
||||||
$count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhembinfilesave');
|
$count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhembinfilesave');
|
||||||
printf "count: $count\n";
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
printf "need to migrate $count files to base64\n";
|
printf "need to migrate $count files to base64\n";
|
||||||
my @toMigrate;
|
my @toMigrate;
|
||||||
@ -345,21 +340,22 @@ sub cfgDB_Init() {
|
|||||||
# close database connection
|
# close database connection
|
||||||
$fhem_dbh->commit();
|
$fhem_dbh->commit();
|
||||||
$fhem_dbh->disconnect();
|
$fhem_dbh->disconnect();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}}
|
}
|
||||||
|
|
||||||
sub _cfgDB_table_exists($$) {
|
sub _cfgDB_table_exists($$) {
|
||||||
my ($dbh,$table) = @_;
|
my ($dbh,$table) = @_;
|
||||||
printf "looking for table fhembinfilesave\n";
|
printf "looking for table fhembinfilesave\n";
|
||||||
my @tables = $dbh->tables('','','','TABLE');
|
my @tables = $dbh->tables('','','','TABLE');
|
||||||
if (@tables) {
|
if (@tables) {
|
||||||
printf "testing 1\n";
|
printf "testing #1\n";
|
||||||
for (@tables) {
|
for (@tables) {
|
||||||
next unless $_;
|
next unless $_;
|
||||||
return 1 if $_ eq $table
|
return 1 if $_ eq $table
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf "testing 2\n";
|
printf "testing #2\n";
|
||||||
eval {
|
eval {
|
||||||
local $dbh->{PrintError} = 0;
|
local $dbh->{PrintError} = 0;
|
||||||
local $dbh->{RaiseError} = 1;
|
local $dbh->{RaiseError} = 1;
|
||||||
@ -367,7 +363,7 @@ sub _cfgDB_table_exists($$) {
|
|||||||
};
|
};
|
||||||
return 1 unless $@;
|
return 1 unless $@;
|
||||||
}
|
}
|
||||||
printf "table not found.\n";
|
printf "table not found\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user