Quiq::Udl - Universal Database Locator
Quiq::Hash
Klasse laden:
use Quiq::Udl;
Objekt instantiieren:
my $udlStr = 'dbi#oracle:xyz%xyz_admin:koala3@pluto.gaga.de:1521'; my $udl = Quiq::Udl->new($udlStr);
UDL-Komponenten:
print $udl->api,"\n"; # dbi print $udl->dbms,"\n"; # oracle print $udl->db,"\n"; # xyz print $udl->user,"\n"; # xyz_admin print $udl->password,"\n"; # koala3 print $udl->host,"\n"; # pluto.gaga.de print $udl->port,"\n"; # 1521 my $optionH = $udl->options; while (($key,$val) = each %$optionH) { print "$key=$val\n"; }
UDL als String:
print $udl->asString,"\n"; # $udlStr
Ein Universal Database Locator (UDL) adressiert eine Datenbank, wie ein Universal Resource Locator eine Web-Resource adressiert.
Ein UDL hat den Aufbau:
api#dbms:db%user:password@host:port;options
Ein Objekt der Klasse kapselt einen UDL und bietet Methoden, um auf die einzelnen Komponenten zuzugreifen. Kommen Metazeichen im Passwort oder den Options vor, können diese mit \ maskiert werden.
Der Name der Schnittstelle (z.B. "dbi").
Der Name der Datenbanksystems (z.B. oracle, postgresql, sqlite, mysql).
Der Name der Datenbank.
Der Name des Benutzers.
Das Passwort des Benutzers.
Der Name des Hosts, auf dem die Datenbank sich befindet.
Der Port, über welchen die Netzverbindung aufgebaut wird.
Referenz auf Hash mit optionalen Angaben.
$udl = $class->new; $udl = $class->new($udlStr); $udl = $class->new(@keyVal);
Instantiiere ein Udl-Objekt und liefere eine Referenz auf dieses Objekt zurück.
$api = $udl->api; $api = $udl->api($api);
$dbms = $udl->dbms; $dbms = $udl->dbms($dbms);
$db = $udl->db; $db = $udl->db($db);
$user = $udl->user; $user = $udl->user($user);
$password = $udl->password; $password = $udl->password($password);
$host = $udl->host; $host = $udl->host($host);
$port = $udl->port; $port = $udl->port($port);
$hash = $udl->options; $hash = $udl->options($str); $hash = $udl->options(@keyVal); $hash = $udl->options(\%hash);
Setze/Liefere Hash mit den UDL-Optionen.
($api,$dbms,$db,$user,$password,$host,$port,$options) = $udl->split($udl);
Zerlege den UDL $udl in seine Komponenten und liefere diese zurück. Für eine Komponente, die nicht im URL enthalten ist, wird ein Leerstring ('') geliefert.
$apiClass = $udl->apiClass;
Liefere die Datanbank API-Klasse. Über diese findet intern der Verbindungsaufbau zur Datenbank statt.
Die API-Klasse für das DBI-API ist:
Quiq::Database::Api::Dbi::Connection
$udlStr = $udl->asString;
Ersetze das Passwort durch einen Stern.
($api,$dbms,$db,$user,$password,$host,$port,$options) = $udl->components;
Liefere die Komponenten des UDL in der oben angegebenen Reihenfolge.
$dsn = $udl->dsn;
Liefere den DSN-String, um per DBI->connect() eine Verbindung zur Datenbank aufzubauen.
$udl->udl($udlStr); $udl->udl(@keyVal); $udlStr = $udl->udl;
Liefere UDL oder setze UDL als Ganzes aus String oder Liste von Schlüssel/Wert-Paaren. Die Methode liefert keinen Wert zurück.
Der Aufruf ohne Parameter ist identisch zum Aufruf von asString().
1.152
Frank Seitz, http://fseitz.de/
Copyright (C) 2019 Frank Seitz
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Quiq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Quiq
CPAN shell
perl -MCPAN -e shell install Quiq
For more information on module installation, please visit the detailed CPAN module installation guide.