-
- rescue PGError => e
- # Pretend like we're database-agnostic in case we ever are.
- raise DatabaseError.new(e)
- end
-
- end
-
-
- protected;
-
- def domain_exists(domain)
- count = 0
-
- # Just assume PostgreSQL for now.
- begin
- connection = PGconn.connect(@db_host,
- @db_port,
- @db_opts,
- @db_tty,
- @db_name,
- @db_user,
- @db_pass)
-
- sql_query = 'SELECT COUNT(domain) as count FROM domain WHERE domain = $1;'
- connection.query(sql_query, [domain.to_s()]) do |result|
- return false if result.ntuples() < 1
- begin
- count = result.getvalue(0,0).to_i()
- return false if count.nil?
- rescue StandardError
- return false
- end
- end
- connection.close()
- rescue PGError => e
- # But pretend like we're database-agnostic in case we ever are.
- raise DatabaseError.new(e)