我已经在我的 macOS v10.13 (High Sierra) 上安装了 DBIish:
zef install DBIish
我的测试脚本是:
use v6;
use DBIish;
my $host='xxx.xx.xxx.xxx';
my $password='abc@123';
my $dbh = DBIish.connect('mysql', :host, :port(3306),
:database<ald_xinen>, :user<aldwx>, :$password);
my $sth = $dbh.do(q:to/STATEMENT/);
DROP TABLE IF EXISTS nom
STATEMENT
$sth = $dbh.do(q:to/STATEMENT/);
CREATE TABLE nom (
name varchar(4),
description varchar(30),
quantity int,
price numeric(5,2)
)
STATEMENT
$sth.finish;
$dbh.dispose;
但是当我运行它时,它得到了这个:
This type cannot unbox to a native string: P6opaque, Bool
in block at /Users/ohmycloud/.rakudobrew/moar-nom/install/share/perl6/site/sources/F2D45FC1BC0A15B4C8511E3A864F1FC1C3F269BB (DBIish) line 41
in any at /Users/ohmycloud/.rakudobrew/moar-nom/install/share/perl6/site/precomp/D3F1031B6C577F31F20F165D75D09B8D4CFEDE2F.1507566035.94084/F2/F2D45FC1BC0A15B4C8511E3A864F1FC1C3F269BB line 1
in method CALL-ME at /Users/ohmycloud/.rakudobrew/moar-nom/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 550
in method connect at /Users/ohmycloud/.rakudobrew/moar-nom/install/share/perl6/site/sources/9FB1D6F036EF609AD1246C9C77F064F5626EAED2 (DBDish::mysql) line 22
in method connect at /Users/ohmycloud/.rakudobrew/moar-nom/install/share/perl6/site/sources/F2D45FC1BC0A15B4C8511E3A864F1FC1C3F269BB (DBIish) line 45
in block <unit> at /Users/ohmycloud/Downloads/u/ald/Documents/scripts/dbiish.p6 line 8
我的乐堂版本是:
This is Rakudo version 2017.09-361-g484f98725 built on MoarVM version 2017.09.1-575-gd4e230a6
implementing Perl 6.c.
那么,我如何让这个脚本工作呢?
最佳答案
您缺少要连接的主机参数上的 $。
关于mysql - Perl 6 DBIish 损坏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46745869/