Perl DBIx sqlite {sqlite_unicode => 1}?

If you are connecting to MySQL with:

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

Connection is forced to utf8;

Connect to SQLite :

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

The connection does not seem to be in utf8;

The goal is to eliminate the need to use decode () when retrieving data: from:

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

at

$cycle->type

thank

+3
source share
1 answer

What to do if you contact this:

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

Perhaps connect()looking for hash-ref options as argument four, not realizing that SQLite does not need username and password arguments.

+8
source

Source: https://habr.com/ru/post/1792146/


All Articles