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.


🦛

  • Comment on Re^3: DBI placeholders for spatial data

Replies are listed 'Best First'.
Re^4: DBI placeholders for spatial data
by Bod (Curate) 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.