Re: connection() dispatch

[prev] [thread] [next] [Date index for 2005/07/06]

From: Matt S Trout
Subject: Re: connection() dispatch
Date: 17:57 on 06 Jul 2005
On Wed, Jul 06, 2005 at 03:50:15PM +0100, webmaster@xxxxxxx.xxx wrote:
> Regarding this error:
> 
> Can't locate object method "connection" via package "Unicorn::DBI" at ...
> 
> This is my first CDBI script and is intended as a proof-of-concept sanity check. I borrowed the example code from the intro of the Class::DBI man page and ran it as:
> 
> package Unicorn::DBI;
> use base 'Class::DBI';
> 
> Unicorn::DBI->connection(db_name, user, pw);
> 
> <snip>
> 
> My guess is that I've failed to properly specify a driver for MySQL. I'm confused as to how DBI.pm and the driver are supposed to link with CDBI. Just 'using' DBD::mysql made no difference. Must I set up the connection via DBI and DBD first? And if so, how is connection() dispatched?

That ... should work. Try Tony's advice on that one, he's had more practice
at this than almost any of us.

As regards drivers, you don't load the DBD yourself, DBI does that
automatically. what you need to do is pass in a DBI DSN (the DBI docs go
into more detail on this) - so, if your MySQL server is called "cup" and
the database you want on it is called "spoon" you'd use

__PACKAGE__->connection('dbi:mysql:host=cup;database=spoon', 'user', 'pass');

        -- 
             Matt S Trout           Website: http://www.shadowcatsystems.co.uk
  Technical Director        E-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.

connection() dispatch
webmaster 14:50 on 06 Jul 2005

Re: connection() dispatch
Tony Bowden 14:54 on 06 Jul 2005

Re: connection() dispatch
Matt S Trout 17:57 on 06 Jul 2005

Re: connection() dispatch
Bogart Salzberg 12:37 on 07 Jul 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52