App-DBBrowser
view release on metacpan or search on metacpan
2.410 2024-05-04
- Derived table/Cte: bugfix in 'choose_query'.
- Bugfix in 'Operators.pm'.
- Refactoring and cleanup.
- SQLite does not have the operators ANY and ALL.
- Term::Choose minimum version 1.765.
2.409 2024-04-28
- SQLite plugin: new option to set the busy timeout.
- SQLite: Renamed and modified the user defined scalar function 'truncate'.
Now 'trunc' treats any value that looks like a number as a number.
- Bugfix in the limit/offset submenu.
- New input filter 'convert datetime'.
- Quote entered numbers if the data type is not numeric and no placeholders are used.
- Added scalar convert functions.
- Epoch_to_DateTime: bugfix and updates.
- Data import: if chosen a deleted directory warn and remove the directory from history.
2.408_05 2024-04-21
- sqlite_busy_timeout.
- Bugfix limit, offset.
bin/db-browser view on Meta::CPAN
=head4 Column/Value/Argument Extensions
Not all of these extensions are available everywhere.
=over
=item Value
Enter a constant value.
If the data type is numeric or undefined and the literal looks like a number, it is not enclosed in quotation marks.
In all other cases, the literal is enclosed in quotation marks.
C<SQLite>: If the option C<sqlite_see_if_its_a_number> is enabled, values that look like numbers are not enclosed in
quotation marks; otherwise, they are.
To enter a value quoted manually, use the C<SQL> menu entry from the C<%%> menu.
=item SQL
Selecting C<SQL> opens the subqueries menu.
bin/db-browser view on Meta::CPAN
Subqueries created with the 'SQL Menu': Allow editing.
When enabled, subqueries created using the 'SQL Menu' can be edited before they are used.
=item
Pg: Convert to C<text> automatically when required.
If the driver is C<Pg>: Convert columns in string functions automatically to C<text> if the datatype of the column is
not a char like datatype. If the datatype is unknown and the value looks like a number, it is also converted to C<text>.
=back
=head2 Create-Table
=head3 Enable Options
=over
=item
lib/App/DBBrowser/Auxil.pm view on Meta::CPAN
package # hide from PAUSE
App::DBBrowser::Auxil;
use warnings;
use strict;
use 5.016;
use Encode qw( decode );
use Scalar::Util qw( looks_like_number );
#use Storable qw(); # required
use DBI::Const::GetInfoType;
use JSON::MaybeXS qw( decode_json );
use List::MoreUtils qw( none );
use Term::Choose qw();
use Term::Choose::Constants qw( EXTRA_W );
use Term::Choose::LineFold qw( line_fold );
lib/App/DBBrowser/Auxil.pm view on Meta::CPAN
sub unquote_identifier {
my ( $sf, $identifier ) = @_;
my $qc = quotemeta( $sf->{d}{identifier_quote_char} );
$identifier =~ s/$qc(?=(?:$qc$qc)*(?:[^$qc]|\z))//g;
return $identifier;
}
sub quote_if_not_numeric {
my ( $sf, $value ) = @_;
if ( looks_like_number $value ) {
return $value;
}
else {
return $sf->{d}{dbh}->quote( $value );
}
}
sub unquote_constant {
my ( $sf, $constant ) = @_;
lib/App/DBBrowser/DB.pm view on Meta::CPAN
App::DBBrowser::DB;
use warnings;
use strict;
use 5.016;
our $VERSION = '2.440';
use Encode qw( decode );
#use bytes; # required
use Scalar::Util qw( looks_like_number );
use DBI::Const::GetInfoType;
sub new {
my ( $class, $info, $opt ) = @_;
my $db_module = "App::DBBrowser::DB::$info->{plugin}";
eval "require $db_module" or die $@;
my $plugin = $db_module->new( $info, $opt );
bless { Plugin => $plugin }, $class;
lib/App/DBBrowser/DB.pm view on Meta::CPAN
if ( $dbh->{Driver}{Name} eq 'SQLite' ) {
$dbh->sqlite_create_function( 'regexp', 3, sub {
my ( $regex, $string, $case_sensitive ) = @_;
$string = '' if ! defined $string;
return $string =~ m/$regex/sm if $case_sensitive;
return $string =~ m/$regex/ism;
}
);
$dbh->sqlite_create_function( 'trunc', -1, sub {
my ( $number, $places ) = @_;
return $number if ! looks_like_number( $number );
$places //= 0;
return int( $number * 10 ** $places ) / 10 ** $places;
}
);
$dbh->sqlite_create_function( 'octet_length', 1, sub {
require bytes;
return if ! defined $_[0];
return bytes::length $_[0];
}
);
lib/App/DBBrowser/DB/SQLite.pm view on Meta::CPAN
my $busy_timeout = delete $sf->{o}{connect_attr}{sqlite_busy_timeout};
my $dsn = "dbi:SQLite:dbname=$db";
my $dbh = DBI->connect( $dsn, '', '', {
PrintError => 0,
RaiseError => 1,
AutoCommit => 1,
ShowErrorStatement => 1,
%{$sf->{o}{connect_attr}//{}}, ##
} );
if ( DBI::looks_like_number( $busy_timeout ) ) { ##
$dbh->sqlite_busy_timeout( 0 + $busy_timeout );
}
return $dbh;
}
sub get_databases {
my ( $sf ) = @_;
return \@ARGV if @ARGV;
my $cache_sqlite_files = sprintf $sf->{i}{db_cache_file_fmt}, $sf->{i}{plugin};
lib/App/DBBrowser/Table/Extensions/ScalarFunctions/To/EpochTo.pm view on Meta::CPAN
package # hide from PAUSE
App::DBBrowser::Table::Extensions::ScalarFunctions::To::EpochTo;
use warnings;
use strict;
use 5.016;
use Scalar::Util qw( looks_like_number );
use List::MoreUtils qw( minmax );
use Term::Choose qw();
use Term::Choose::Util qw( get_term_height );
use App::DBBrowser::Auxil;
sub new {
lib/App/DBBrowser/Table/Extensions/ScalarFunctions/To/EpochTo.pm view on Meta::CPAN
}
sub __guess_interval {
my ( $sf, $sql, $func, $col, $epochs, $max_examples ) = @_;
my ( $function_stmt, $example_results );
if ( ! eval {
my %count;
for my $epoch ( @$epochs ) {
if ( ! looks_like_number( $epoch ) ) {
return;
}
++$count{length( $epoch )};
}
if ( keys %count != 1 ) {
return;
}
my $epoch_w = ( keys %count )[0];
my $interval;
if ( $epoch_w <= 10 ) {
( run in 1.816 second using v1.01-cache-2.11-cpan-39bf76dae61 )