+ def get_domains_from_db()
+ # Just assume PostgreSQL for now.
+ begin
+ connection = PGconn.connect(@db_host,
+ @db_port,
+ @db_opts,
+ @db_tty,
+ @db_name,
+ @db_user,
+ @db_pass)
+
+ # 'ALL' is a magic domain, and we don't want it.
+ sql_query = "SELECT domain FROM domain WHERE domain <> 'ALL';"
+ result = connection.query(sql_query)
+ connection.close()
+ rescue PGError => e
+ # But pretend like we're database-agnostic in case we ever are.
+ raise DatabaseError.new(e)
+ end
+
+ # The database query returns an array of rows. Since we only asked
+ # for one column (domain), we can flatten the result into an
+ # array of domains.
+ return result.flatten
+ end
+
+