Perl
要在Perl中使用LiteSync,我们必须做两件事:
1.用我们编译的包含LiteSync的库替换预安装的SQLite库。
2.编译DBD:SQLite以使用已安装的SQLite模块:
Linux
wget http://search.cpan.org/CPAN/authors/id/I/IS/ISHIGAKI/DBD-SQLite-1.54.tar.gz
tar zxvf DBD-SQLite-1.54.tar.gz
cd DBD-SQLite-1.54
sed -i 's/if ( 0 ) {/if ( 1 ) {/g' Makefile.PL
perl Makefile.PL USE_LOCAL_SQLITE=0 SQLITE_LOCATION=/usr
make
sudo make install
Windows
To do
使用方法
然后,我们可以正常使用DBI/DBD:SQLite模块,并传递一个特殊的URI。
代码示例:
use DBI;
my $dbh = DBI->connect("dbi:SQLite:uri=file:data.db?node=secondary&connect=tcp://server:port")
$dbh->do('CREATE TABLE t1 (id, name)');
$dbh->do('INSERT INTO t1 VALUES (1, "Hello World!")');
# wait for the new data to be replicated - only needed if the app will be closed
sleep(5);
print "done\n";