Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: DBI placeholders for spatial data

by hippo (Bishop)
on Jun 26, 2021 at 08:37 UTC ( [id://11134318]=note: print w/replies, xml ) Need Help??


in reply to Re^2: DBI placeholders for spatial data
in thread DBI placeholders for spatial data

Sorry - I should have included that it is MariaDB.

It would also be helpful to know which version of MariaDB you are connecting to and also which DBD driver (and version) you are using to make that connection.


🦛

Replies are listed 'Best First'.
Re^4: DBI placeholders for spatial data
by Bod (Parson) on Jun 26, 2021 at 10:12 UTC

    10.2.39-MariaDB

    I was using DBD::mysql until yesterday when I switched this project to DBD::MariaDB. I'm still using the MySQL driver for other projects that don't require spatial data.

    However, I cannot find DBD::MariaDB listed amongst the installed modules so I am struggling to find the version of that! DBD::mysql is version 4.050

    edit:

    Running cpan -D DBD::MariaDB tells me that the module is not installed!

    However, DBI->connect("DBD:MariaDB:database=xxx", $user, $pass); connects without problem.

    Further edit

    foreach my $driver(DBI->available_drivers) { print "$driver\n"; }
    Produces:
    DBM ExampleP File Gofer Mem Pg Proxy SQLite SQLite2 Sponge mysql
    So I guess that DBI->connect("DBD:MariaDB:database=... is using some form of default driver.

      However, DBI->connect("DBD:MariaDB:database=xxx", $user, $pass); connects without problem.

      [...]

      So I guess that DBI->connect("DBD:MariaDB:database=... is using some form of default driver.

      It works only by accident, or because DBI is quite relaxed regarding the data source argument to connect(). The DBI documentation clearly states:

      connect

      $dbh = DBI->connect($data_source, $username, $password) or die $DBI::errstr; $dbh = DBI->connect($data_source, $username, $password, \%attr) or die $DBI::errstr;
      [...]

      The $data_source value must begin with "dbi:driver_name:". The driver_name specifies the driver that will be used to make the connection. (Letter case is significant.)

      [...]

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        I think this is the important part of the documentation

        As a convenience, if the $data_source parameter is undefined or empty, the DBI will substitute the value of the environment variable DBI_DSN. If just the driver_name part is empty (i.e., the $data_source prefix is "dbi::"), the environment variable DBI_DRIVER is used. If neither variable is set, then connect dies.

        I guess that the environment variable DBI_DRIVER is set to mysql as that is the RDBMS installed on the server.

      That's odd.

      $ cpan -D DBD::MariaDB DBD::MariaDB ---------------------------------------------------------------------- +--- (no description) P/PA/PALI/DBD-MariaDB-1.21.tar.gz /Users/1nickt/.perlbrew/libs/perl-5.32.1@meta/lib/perl5/darwin-2le +vel/DBD/MariaDB.pm Installed: 1.21 CPAN: 1.21 up to date Pali (PALI) pali@cpan.org
      $ perl -MDBD::MariaDB -E 'say $DBD::MariaDB::VERSION' 1.21


      The way forward always starts with a minimal test.

        For me perl -MDBD::MariaDB -e 'print $DBD::MariaDB::VERSION' tells me Can't locate DBD/MariaDB.pm in @INC.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 02:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found