我正在尝试使用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文件夹中为新架构创建新文件夹?
答案 0 :(得分:0)
迟到10个月我意识到,偶然发现了寻找别的东西。您的make_schema_at
电话错误。
make_schema_at( $schema, \%loader_options, [$dsn, $user, $pass] );
你传入一个ArrayRef,其中make_schema_at期待一个HashRef。
尝试
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',''])“