chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove the clone-and-hack database initialisation from web scripts
[ypp-sc-tools.main.git]
/
yarrg
/
CommodsDatabase.pm
diff --git
a/yarrg/CommodsDatabase.pm
b/yarrg/CommodsDatabase.pm
index 6f2f6274e09d5b72ddc535d26565eda0757e9acf..2ea674d6963e489647b779fb880b464931fc1684 100644
(file)
--- a/
yarrg/CommodsDatabase.pm
+++ b/
yarrg/CommodsDatabase.pm
@@
-44,7
+44,7
@@
BEGIN {
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(&db_setocean &db_writer &db_connect $dbh
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(&db_setocean &db_writer &db_connect $dbh
- &db_filename &db_doall &db_onconflict);
+ &db_filename &db_doall &db_onconflict
&db_setdatadir
);
%EXPORT_TAGS = ( );
@EXPORT_OK = qw();
%EXPORT_TAGS = ( );
@EXPORT_OK = qw();
@@
-52,10
+52,14
@@
BEGIN {
our $dbfn;
our $dbh;
our $dbfn;
our $dbh;
+our $datadir= '.';
+sub db_setdatadir ($) {
+ $datadir= $_[0];
+}
sub db_setocean ($) {
my ($oceanname) = @_;
sub db_setocean ($) {
my ($oceanname) = @_;
- $dbfn= "OCEAN-$oceanname.db";
+ $dbfn= "
$datadir/
OCEAN-$oceanname.db";
}
sub db_filename () {
return $dbfn;
}
sub db_filename () {
return $dbfn;
@@
-89,6
+93,7
@@
sub db_writer () {
}
sub db_connect () {
}
sub db_connect () {
+ return if $dbh;
$dbh= DBI->connect("dbi:SQLite:$dbfn",'','',
{ AutoCommit=>0,
RaiseError=>1, ShowErrorStatement=>1,
$dbh= DBI->connect("dbi:SQLite:$dbfn",'','',
{ AutoCommit=>0,
RaiseError=>1, ShowErrorStatement=>1,