X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=sync.pl;h=113df7d93ba04ae3b0cc07ce0696016c8e145bab;hb=fde909c294de9806dd6337f5acb0ed87c41557c6;hp=d57af449979c05672fc658b0c930e7e28cf744ef;hpb=1fac0677bbcba5dec26e11aa661c97e38f6c3d40;p=wloh diff --git a/sync.pl b/sync.pl index d57af44..113df7d 100755 --- a/sync.pl +++ b/sync.pl @@ -5,18 +5,15 @@ use warnings; no warnings qw(once); use Encode; use Time::HiRes; -require './config.pm'; +use lib qw( include ); +require 'config.pm'; sub copy_escape { my $x = shift; if (!defined($x)) { return '\N'; } - $x = Encode::decode('iso8859-1', $x); - $x =~ s/\\/\\\\/g; - $x =~ s/\r/\\r/g; - $x =~ s/\n/\\n/g; - $x =~ s/\t/\\t/g; + $x =~ s/([\\\r\n\t])/\\$1/g; return $x; } @@ -48,6 +45,7 @@ my $sdbh = DBI->connect($config::local_connstr, $config::local_username, $config or die "PostgreSQL connect: " . $DBI::errstr; $sdbh->{AutoCommit} = 0; $sdbh->{RaiseError} = 1; +$sdbh->do("SET client_encoding TO 'iso8859-1';"); # For our own enjoyment. sync_table($mdbh, $sdbh, "Fotballbrukere");