def db_query(self, client_id, msg):
content = msg['<STR_LIT:content>']<EOL>query = content.get('<STR_LIT>', {})<EOL>keys = content.get('<STR_LIT>', None)<EOL>buffers = []<EOL>empty = list()<EOL>try:<EOL><INDENT>records = self.db.find_records(query, keys)<EOL><DEDENT>except Exception as e:<EOL><INDENT>content = error.wrap_exception()<EOL><DEDENT>else:<EOL><INDENT>if keys is not None:<EOL><INDENT>buffer_lens = [] if '<STR_LIT>' in keys else None<EOL>result_buffer_lens = [] if '<STR_LIT>' in keys else None<EOL><DEDENT>else:<EOL><INDENT>buffer_lens = None<EOL>result_buffer_lens = None<EOL><DEDENT>for rec in records:<EOL><INDENT>b = rec.pop('<STR_LIT>', empty) or empty<EOL>if buffer_lens is not None:<EOL><INDENT>buffer_lens.append(len(b))<EOL>buffers.extend(b)<EOL><DEDENT>rb = rec.pop('<STR_LIT>', empty) or empty<EOL>if result_buffer_lens is not None:<EOL><INDENT>result_buffer_lens.append(len(rb))<EOL>buffers.extend(rb)<EOL><DEDENT><DEDENT>content = dict(status='<STR_LIT>', records=records, buffer_lens=buffer_lens,<EOL>result_buffer_lens=result_buffer_lens)<EOL><DEDENT>self.session.send(self.query, "<STR_LIT>", content=content,<EOL>parent=msg, ident=client_id,<EOL>buffers=buffers)<EOL>
Perform a raw query on the task record database.