perl DBIx sqlite {sqlite_unicode=>1}?

2023-11-29

如果连接到MySQL with:

my $schema = MyDatabase::Main->connect("dbi:mysql:database=$database;host=$host",'root','', {mysql_enable_utf8 => 1});

连接强制为utf8;

连接到SQLite:

my $schema = MyDatabase::Main->connect('dbi:SQLite:data/sample.db', {sqlite_unicode => 1});

连接好像不是utf8;

目的是消除在获取数据时必须使用decode(): 从:

Mojo::ByteStream->new($cycle->type)->decode('utf-8')

to:

$cycle->type

Thanks


如果你用这个连接怎么办:

my $schema = MyDatabase::Main->connect(
    'dbi:SQLite:data/sample.db',
    '', # empty username
    '', # empty password
    {sqlite_unicode => 1}
);

Maybe connect()正在寻找选项 hash-ref 作为参数四,但没有意识到 SQLite 不需要用户名和密码参数。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

perl DBIx sqlite {sqlite_unicode=>1}? 的相关文章

随机推荐