# Thanks to the ON DELETE triggers, this will remove all child
# records associated with user_id too.
- sql_queries = ['DELETE FROM users WHERE user_id = $1::int;']
+ sql_query = 'DELETE FROM users WHERE user_id = $1::int;'
- connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
- @db_name, @db_user, @db_pass)
+ connection = PG::Connection.new(@db_hash)
- sql_queries.each do |sql_query|
- connection.query(sql_query, [user_id])
+ begin
+ connection.sync_exec_params(sql_query, [user_id])
+ ensure
+ # Make sure the connection gets closed even if the query explodes.
+ connection.close()
end
-
- connection.close()
end
end