aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2008-01-02 19:45:03 +0000
committerRalph Amissah <ralph@amissah.com>2008-01-02 19:45:03 +0000
commit084433a84b1d850187663e10492dda544923a681 (patch)
tree3f307efd7da95c9808bdc38dbe25d27e72b2be04 /lib
parentyear updated to 2008 - happy new year (diff)
sql, postgresql allow tcp/ip connections, parameters from rc file, sisurc.yml
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v0/dbi.rb4
-rw-r--r--lib/sisu/v0/sysenv.rb13
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/sisu/v0/dbi.rb b/lib/sisu/v0/dbi.rb
index c787a60e..2e633bad 100644
--- a/lib/sisu/v0/dbi.rb
+++ b/lib/sisu/v0/dbi.rb
@@ -93,8 +93,8 @@ module SiSU_DBI
end
def read_psql
begin
- db,user,dbi=@db.psql.db,@db.psql.user,@db.psql.dbi
- @conn=DBI.connect(dbi,user,db)
+ db,user,dbi,pass=@db.psql.db,@db.psql.user,@db.psql.dbi,@db.psql.password
+ @conn=DBI.connect(dbi,user,pass)
rescue
if @opt.mod.inspect=~/--(createall|create)/
puts %{manually create the database: "#{db}" if it does not yet exist}
diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb
index b4252e28..4187f6e9 100644
--- a/lib/sisu/v0/sysenv.rb
+++ b/lib/sisu/v0/sysenv.rb
@@ -2648,6 +2648,19 @@ WOK
else ''
end
end
+ def host
+ if defined? @rc['db']['postgresql']['host'] \
+ and @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/
+ @rc['db']['postgresql']['host']
+ else ''
+ end
+ end
+ def dbi
+ if psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/
+ "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}"
+ else "DBI:Pg:database=#{psql.db};port=#{psql.port}"
+ end
+ end
self
end
def mysql