1

我正在尝试使用 DBIx::Class::Schema::Loader 从现有的 MySQL 数据库创建模式。我使用了这样的 make_schema_at 方法:

C:\xampp\perl\bin>perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:.\lib -e "make_schema_at('turboimmisoft::Schema', ['dbi::mysql::dbname=turboimmisoft', 'root', ''])"

其中:turboimmisoft 是我的数据库的名称

我收到以下错误消息:

Reference found where even-sized list expected at C:/xampp/perl/site/lib/DBIx/Class/Schema/Loader.pm line 165.
DBIx::Class::Storage::DBI::_connect(): You did not provide any connection_info at -e line 1
[download]
I am using ActivePerl 5.14.4 on Windows Vista and the path the the MySQL database is: "C:\xampp\mysql\data\". The path to perl.exe is: "C:\xampp\perl\bin\"

要使用 DBI(不是 DBIx::Class)连接到 MySQL 数据库,我使用:

use DBI;
my $driver = "mysql"; 
my $database = "turboimmisoft";
my $dsn = "DBI:$driver:database=$database";
my $userid = "root";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password)   #, {RaiseError => 1
+, AutoCommit => 1}
          or die "Could not connect to database:$DBI::errstr"; 

任何帮助将不胜感激。我是 DBIx::Class 的新手,但自 2007 年以来我一直在使用 DBI。

我是否必须在 DBIx::Class 文件夹中为新架构创建新文件夹?

4

1 回答 1

0

10 months late I realize, stumbled across this searching for something else. Your make_schema_at call is wrong.

make_schema_at( $schema, \%loader_options, [$dsn, $user, $pass] );

make_schema_at documentation

you are passing in an ArrayRef where make_schema_at is expecting a HashRef.

Try

C:\xampp\perl\bin>perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:.\lib -e "make_schema_at('turboimmisoft::Schema', { debug => 1 }, ['dbi:mysql:dbname=turboimmisoft', 'root', ''])"

于 2014-05-29T01:03:26.177 回答