Stop pretending that we'll ever work with another DBMS.
[mailshears.git] / lib / rm / plugins / agendav.rb
1 require 'pg'
2
3 require 'common/agendav_plugin'
4 require 'rm/rm_plugin'
5
6 class AgendavRm
7
8 include AgendavPlugin
9 include RmPlugin
10
11
12 def delete_user(user)
13 # Delete the given username and any records in other tables
14 # belonging to it.
15 raise NonexistentUserError.new(user.to_s()) if not user_exists(user)
16
17 sql_queries = ['DELETE FROM prefs WHERE username = $1;']
18 sql_queries << 'DELETE FROM shared WHERE user_from = $1;'
19
20 connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
21 @db_name, @db_user, @db_pass)
22
23 sql_queries.each do |sql_query|
24 connection.query(sql_query, [user.to_s()])
25 end
26
27 connection.close()
28 end
29
30 end