biblesearch / tmp / insert_content.pl /
Newer Older
21 lines | 0.411kb
add content to database
Yuki Kimoto authored on 2014-03-27
1
use strict;
2
use warnings;
3
use DBIx::Custom;
4
use Encode 'decode';
5

            
6
my ($book_id) = $ARGV[0] =~ /(\d+)/;
7

            
8
my @lines;
9
while (my $line = <>) {
10
  push @lines, decode('UTF-8', $line);
11
}
12

            
13
my $content = join '', @lines;
14

            
15
my $dbi = DBIx::Custom->connect(
16
  dsn => "dbi:SQLite:dbname=../db/bible.db",
17
  option => {sqlite_unicode => 1}
18
);
19

            
20
$dbi->update({content => $content}, table => 'book', where => {id => $book_id});
21