Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: What is the proper data structure for CAP::DBH?

by hv (Prior)
on Jan 18, 2023 at 02:44 UTC ( #11149662=note: print w/replies, xml ) Need Help??


in reply to What is the proper data structure for CAP::DBH?

You say: DBI docs suggest this format for the data structure

    $data_source = dbi:DriverName:database=database_name;host=hostname

So, I have set up the connection to look like this:

my $data_source = 'DBI:mysql:'. $self->config_param('mysql.database').':'. $self->config_param('mysql.host');

However the first part suggests it should rather look like this (note also the semicolon in the string):

my $data_source = 'DBI:mysql:database='. $self->config_param('mysql.database').';host='. $self->config_param('mysql.host');

So maybe you should try that first.

In fact I'd probably prefer to construct a string like that with sprintf:

my $data_source = sprintf 'DBI:mysql:database=%s;host=%s', $self->config_param('mysql.database'), $self->config_param('mysql.host');

Replies are listed 'Best First'.
Re^2: What is the proper data structure for CAP::DBH?
by bradcathey (Prior) on Jan 18, 2023 at 13:44 UTC

    Thanks for the suggestions. Unfortunately, no form of those work. It just hangs. No error message even though I have set: use CGI::Carp qw(fatalsToBrowser);

    I tried with both a semi-colon and colon between the database name and host name but no joy. Just to be sure, Data Dumper showed:

    'DBI:mysql:highgatevps_kcmach;vdb2b.pair.com'

    I'll reach out to Pair and see if their logs show the issue (nothing in the logs they provide for users).

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      'DBI:mysql:highgatevps_kcmach;vdb2b.pair.com'

      The keywords database and host are still missing.


      🦛

        I tried it every way, but just hangs.

        $VAR1 = 'DBI:mysql:database=highgatevps_kcmach;host=vdb2b.pair.com';

        On another note, why use sprintf? Elegance? I've always used it for formatting numbers, but not in the way hv did. Nice.

        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2023-10-03 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?