]>
gitweb.michael.orlitzky.com - mailshears.git/blob - src/postfixadmin_db.rb
5 def initialize(db_host
,
23 def get_domains_from_db()
24 # Just assume PostgreSQL for now.
26 connection
= PGconn
.connect(@db_host,
34 # 'ALL' is a magic domain, and we don't want it.
35 sql_query
= "SELECT domain FROM domain WHERE domain <> 'ALL';"
36 result
= connection
.query(sql_query
)
39 # But pretend like we're database-agnostic in case we ever are.
40 raise DatabaseError
.new(e
)
43 # The database query returns an array of rows. Since we only asked
44 # for one column (domain), we can flatten the result into an
50 def get_accounts_from_db()
51 # Just assume PostgreSQL for now.
53 connection
= PGconn
.connect(@db_host,
61 # If address = goto, then the alias basically says, "really
62 # deliver to that address; it's not an alias."
63 sql_query
= 'SELECT username FROM mailbox;'
64 result
= connection
.query(sql_query
)
67 # But pretend like we're database-agnostic in case we ever are.
68 raise DatabaseError
.new(e
)
71 # The database query returns an array of rows. Since we only asked
72 # for one column (address), we can flatten the result into an