Add file to database

This commit is contained in:
zyppe 2025-02-24 22:28:20 +08:00
parent 54e6b0a139
commit 80e3c8cc3a
3 changed files with 66 additions and 48 deletions

View file

@ -4,9 +4,7 @@ use warnings;
use v5.26;
use Carp;
use Data::Dumper;
use File::Find;
use SQL::Abstract;
use DBI;
my $db =
@ -14,17 +12,18 @@ my $db =
or confess $DBI::errstr;
sub sqlstr {
my ( $table, $primary ) = @_;
return qq
/create table if not exists @_ (
id integer primary key autoincrement,
/create table if not exists $table (
id integer / . ( $primary ? 'primary key autoincrement' : '' ) . qq/,
title text,
filepath text,
content text
);/;
}
my %tablesql = (
"origin" => sqlstr("origin"),
"trans" => sqlstr("trans"),
"origin" => sqlstr( "origin", 1 ),
"trans" => sqlstr( "trans", 0 ),
);
my $act;
for my $table ( keys %tablesql ) {

View file

@ -8,8 +8,12 @@ use Time::Piece;
use Digest::SHA qw(sha256_hex hmac_sha256_hex);
use JSON::MaybeXS qw(encode_json);
use Exporter 'import';
our @EXPORT_OK = 'sign';
sub sign {
my $SourceText = @_;
carp "You must provide SecretKey.csv to parent folder!";
our $SourceText ;
my $data = {
SourceText => $SourceText,
Source => 'en',
@ -66,7 +70,8 @@ my $SecretService = hmac_sha256_hex( $SecretDate, $service );
my $SecretSigning = hmac_sha256_hex( $SecretService, "tc3_request" );
my $Signature = hmac_sha256_hex( $SecretSigning, $StringToSign );
our $Authorization =
my $Authorization =
"$Algorithm Credential=$SecretID/$CredentialScope, SignedHeaders=$SignedHeaders, Signature=$Signature";
return $Authorization;
}
say $payload;

14
Translator/translate.pl Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/perl
use strict;
use warnings;
use v5.26;
use Carp;
use File::Find;
use DBI;
use lib 'sign.pl';
my $db =
DBI->connect( "DBI:SQLite:dbname=../data.db", "", "", { RaiseError => 1 } )
or confess $DBI::errstr;