in reply to Re: How to use DBIx::Class::Schema::Loader to create schema from an existing MySQL database?
in thread How to use DBIx::Class::Schema::Loader to create schema from an existing MySQL database?

Are the following my \%loader_options? { debug => 1, dump_directory => '.\lib', },

I tried, but I got the following error message:

DBIx::Class::Storage::DBI::_connect(): DBI Connection failed: DBI conn +ect('dbname="turboimmisoft"','root',...) failed: Unknown database '"t +urboimmisoft"' at C:/xampp/perl/site/lib/DBIx/Class/Storage/DBI.pm li +ne 1395.

Can anyone write the right code for me please? I wasted an entire day on this. In MySQL, the database is made up a folder containing the tables. That folder is named turboimmisoft (same name as the database). There is no more folder in turboimmisoft.

Some info:

1. Path to the MySQL database:C:\xampp\mysql\data\turboimmisoft\

2. Path to per.exe: C:\xampp\perl\bin\

3. Connection info with DBI: my $driver = "mysql"; my $database = "turboimmisoft"; my $dsn = "DBI:$driver:database=$database"; my $userid = "root"; my $password = "";

  • Comment on Re^2: How to use DBIx::Class::Schema::Loader to create schema from an existing MySQL database?
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: How to use DBIx::Class::Schema::Loader to create schema from an existing MySQL database?
by kcott (Archbishop) on Aug 01, 2013 at 06:39 UTC
    "I tried, but I got the following error message: ..."

    "I tried" doesn't tell us what you tried, so we're somewhat in the dark there; however, perhaps jumping directly to the error message will prove useful. What did you see when you looked at line 1395 of C:/xampp/perl/site/lib/DBIx/Class/Storage/DBI.pm? [Correct me if I'm wrong: you didn't look, did you?] In my copy of that code, I see:

    $dbh = DBI->connect(@info);

    Look familiar? Now look at the line just before that (i.e. 1394):

    require DBI;

    So, the connection is being made using DBI's connect() method.

    One key phrase that stands out:

    The $data_source value must begin with "dbi:driver_name:".

    Note that's dbi (in lowercase) and single colons are used!

    The next paragraph goes on to explain what happens if

    the driver_name part is empty (i.e., the $data_source prefix is "dbi::")

    I recommend you read more than just those snippets I've pointed to; however, that may be enough for you to resolve your problems.

    "I wasted an entire day on this."

    Or, alternatively, you could take the silver lining view:

    "I spent an entire day that I'll never forget. I learnt valuable lessons about troubleshooting and reading documentation that I'll never forget either."

    -- Ken