def exec_op(self, op, receiver, sender=None): cur = self.conn.cursor() s_id = Client.get_client_id(sender) r_id = receiver.client_id q_id = Queue.get_queue_id(self) cur.execute("SELECT * FROM {0}(%s, %s, %s)".format(op), (r_id, q_id, s_id)) res = cur.fetchone() cur.close() return res
def send_message(self, sender, receiver=None, content=None): r_id = Client.get_client_id(receiver) s_id = sender.client_id cur = self.conn.cursor() if content is None: content = "{0}".format(time.time()) cur.execute("""SELECT * FROM send_message( %s, %s, %s, %s)""", (self.queue_id, s_id, r_id, content)) msg = cur.fetchone() cur.close() return msg