From 084433a84b1d850187663e10492dda544923a681 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 2 Jan 2008 19:45:03 +0000 Subject: sql, postgresql allow tcp/ip connections, parameters from rc file, sisurc.yml --- lib/sisu/v0/dbi.rb | 4 ++-- lib/sisu/v0/sysenv.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3