]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/postfixadmin_db.rb
5 def initialize(db_host
,
23 def get_domains_from_db()
26 # Just assume PostgreSQL for now.
28 connection
= PGconn
.connect(@db_host,
36 # 'ALL' is a magic domain, and we don't want it.
37 sql_query
= "SELECT domain FROM domain WHERE domain <> 'ALL';"
38 connection
.query(sql_query
) do |result
|
39 domains
= result
.field_values('domain')
43 # But pretend like we're database-agnostic in case we ever are.
44 raise DatabaseError
.new(e
)
51 def get_accounts_from_db()
54 # Just assume PostgreSQL for now.
56 connection
= PGconn
.connect(@db_host,
64 # If address = goto, then the alias basically says, "really
65 # deliver to that address; it's not an alias."
66 sql_query
= 'SELECT username FROM mailbox;'
67 connection
.query(sql_query
) do |result
|
68 accounts
= result
.field_values('username')
72 # But pretend like we're database-agnostic in case we ever are.
73 raise DatabaseError
.new(e
)