App::DBBrowser::DB - Database plugin documentation.
Version 2.223
A database plugin provides the database specific methods. App::DBBrowser considers a module whose name matches /^App::DBBrowser::DB::[^:']+\z/ and which is located in one of the @INC directories as a database plugin.
App::DBBrowser
/^App::DBBrowser::DB::[^:']+\z/
@INC
The user can add an installed database plugin to the available plugins in the options menu (db-browser -h) by selecting DB Options and then DB Plugins.
db-browser -h
A suitable database plugin provides the methods named in this documentation.
The constructor method.
When db-browser calls the plugin constructor it passes tow arguments:
db-browser
sub new { my ( $class, $info, $opt ) = @_; my $self = { info => $info, opt => $opt }; return bless $self, $class; } # $info->{app_dir} -> path to the configuration directoriy of the app # $info->{sqlite_search} -> true if C<db-browser> was called with the argument C<-s|--search> # $opt->{G}{metadata} -> Options/Sql/Metadata
Returns the created object.
Returns the name of the DBI database driver used by the plugin.
DBI
Returns two array references: the first reference refers to the array of user-databases the second refers to the array of system-databases. The second array reference is optional.
If the option metadata is true, user-databases and system-databases are used else only the user-databases are used.
Returns the database handle.
db-browser expects a DBI database handle with the attribute RaiseError enabled.
$dbh is the database handle returned by the method db_hanlde.
$dbh
db_hanlde
Returns the user-schemas as an array-reference and the system-schemas as an array-reference (if any).
If the option metadata is true, user-schemas and system-schemas are used else only the user-schemas are used.
package App::DBBrowser::DB::MyPlugin; use strict; use DBI; sub new { my ( $class ) = @_; return bless {}, $class; } sub get_db_driver { my ( $self ) = @_; return 'Pg'; } sub get_db_handle { my ( $self, $db ) = @_; my $dbh = DBI->connect( "DBI:Pg:dbname=$db", 'user', 'password', { RaiseError => 1, PrintError => 0, }) or die $DBI::errstr; return $dbh; } sub get_databases { my ( $self ) = @_; return [ 'My_DB_1', 'My_DB_2' ]; } 1;
Matthäus Kiem <cuer2s@gmail.com>
Copyright 2012-2019 Matthäus Kiem.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For details, see the full text of the licenses in the file LICENSE.
To install App::DBBrowser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::DBBrowser
CPAN shell
perl -MCPAN -e shell install App::DBBrowser
For more information on module installation, please visit the detailed CPAN module installation guide.