Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Multiple file handles

by MoodyDreams999 (Scribe)
on Apr 07, 2023 at 21:44 UTC ( [id://11151521]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Multiple file handles
in thread Multiple file handles

Thats actually a really good idea, We do use alot json stuff here, this might be a simpler way for me to do this, because I'd like to create 2 versions where I can run one on my machine, then use another to reference the database, but still not sure if I could reference mysql database on my local machine. i'll post more data once I get that connection working. This is what I have so far though.
my $database = "asterisk"; my $user = "root"; my $host = 192.168.8.50; my $password = 123; my $dbhA = DBI->connect("DBI:mysql:$database,$host","$password") o +r die "Couldn't connect to database: ".DBI->errstr;
using DBI What would you recommed DBI vs DBD::mysql?

Replies are listed 'Best First'.
Re^4: Multiple file handles
by 1nickt (Canon) on Apr 08, 2023 at 10:41 UTC

    DBI is the plumbing; DBD::mysql is the fitting. You need both.

    From the doc for DBD::mysql (plus your error handling):

    my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; my $dbh = DBI->connect($dsn, $user, $password) or die "Couldn't connec +t to database: ".DBI->errstr;
    Set up all those variables then use that exact code snippet and it should work for you.

    Hope this helps!


    The way forward always starts with a minimal test.
      Yeah, that helped alot, I was trying to find an example where they use the dsn in the connect statement, wasn't sure I was doing it right since it kept failing, probably just need to make sure its got the right credentials since we have like 5 different servers for similar things.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-06-15 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.