perl DBIx sqlite {sqlite_unicode=>1}?
如果连接到 MySQL 时:
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')
至:
$cycle->type
谢谢
If connecting to MySQL with:
my $schema = MyDatabase::Main->connect("dbi:mysql:database=$database;host=$host",'root','', {mysql_enable_utf8 => 1});
The connection is forced to utf8;
Connect to SQLite:
my $schema = MyDatabase::Main->connect('dbi:SQLite:data/sample.db', {sqlite_unicode => 1});
The connection seems not to be in utf8;
The purpose is to eliminate having to use decode() while fetching data:
from:
Mojo::ByteStream->new($cycle->type)->decode('utf-8')
to:
$cycle->type
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你用这个连接怎么办:
也许
connect()
正在寻找选项 hash-ref 作为参数四,而没有意识到 SQLite 不需要用户名和密码参数。What if you connect with this:
Maybe
connect()
is looking for the options hash-ref as argument four without realizing that SQLite doesn't need the username and password arguments.