Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable support for multiple DBDI drivers.

  • Loading branch information...
commit e0c7a61cff083ba8fe247a9b0598eff93d95a7a9 1 parent 28e0ca2
@timbunce authored
Showing with 6 additions and 3 deletions.
  1. +5 −2 DBDI_pg.pm6
  2. +1 −1  dbdi.pl6
View
7 DBDI_pg.pm6
@@ -110,14 +110,17 @@ class DBDI_pg::Driver does java::sql::Driver {
DBDI::DriverManager.registerDriver( DBDI_pg::Driver.new );
-
multi method connect (
- Str $url,
+ Str $url is copy,
Hash $prop,
--> java::sql::Connection
) {
say "> connect '$url'";
+
+ return fail() if not $url ~~ s/^dbdi\:postgres\://;
+
my $conninfo = "host=localhost $url user=$prop.<user> password=$prop.<password>";
+ say "- connect '$conninfo'";
my $db_conn = PQconnectdb($conninfo);
if (PQstatus($db_conn) != CONNECTION_OK) {
my $msg = PQerrorMessage($db_conn);
View
2  dbdi.pl6
@@ -5,7 +5,7 @@ use DBDI_pg;
my $dbname = @*ARGS.shift || prompt 'Database: ';
-my $con = DBDI::DriverManager.getConnection("dbname=$dbname", 'testuser', 'testpass');
+my $con = DBDI::DriverManager.getConnection("dbdi:postgres:dbname=$dbname", 'testuser', 'testpass');
while prompt 'SQL: ' -> $sql {
Please sign in to comment.
Something went wrong with that request. Please try again.