Make dbhost configureable

svn:r12600
This commit is contained in:
Peter Palfrader 2007-11-29 11:20:26 +00:00
parent 30cbcaecc5
commit 423293dead
5 changed files with 13 additions and 6 deletions

View File

@ -30,7 +30,7 @@ require 'db-config'
verbose = ARGV.first == "-v"
db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
db.transaction_begin
named = db.query2("

View File

@ -1,6 +1,8 @@
$CONFIG = {} unless $CONFIG
$CONFIG['database'] = {} unless $CONFIG['database']
# if you use postgres' "ident sameuser" auth set dbhost to ''
$CONFIG['database']['dbhost'] = 'localhost';
$CONFIG['database']['dbname'] = 'tornaming';
$CONFIG['database']['user'] = 'tornaming';
$CONFIG['database']['password'] = 'x';

View File

@ -39,8 +39,8 @@ class WeaselDbQueryHandle
end
class Db
def initialize(database, user, password)
@dbh = DBI.connect("dbi:Pg:#{database}:localhost", user, password);
def initialize(host, database, user, password)
@dbh = DBI.connect("dbi:Pg:#{database}:#{host}", user, password);
@dbh['AutoCommit'] = false
@transaction = false
@pre_initial_transaction=true

View File

@ -31,7 +31,7 @@ require 'db'
require 'db-config'
require 'update-named-status'
$db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
$db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
$router_cache = {}
$nickname_cache = {}

View File

@ -28,7 +28,12 @@ require 'db'
require 'db-config'
def do_update(verbose)
now = "TIMESTAMP '" + $db.query_row("SELECT max(last_seen) AS max FROM router_claims_nickname")['max'].to_s + "'"
now = $db.query_row("SELECT max(last_seen) AS max FROM router_claims_nickname")['max']
unless now == ''
STDERR.puts "Could not find the latest last_seen timestamp. Is the database empty still?"
return
end
now = "TIMESTAMP '" + now.to_s + "'"
denamed = $db.do("
UPDATE router_claims_nickname
@ -56,7 +61,7 @@ def do_update(verbose)
end
if __FILE__ == $0
$db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
$db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
verbose = ARGV.first == "-v"
$db.transaction_begin