class_docstr: Uses handler's database to store and retrieve messages
class_docstr_tok: ["Uses","handler","'s","database","to","store","and","retrieve","messages"]
code: def _get_chat_history(self, chat_id):
      t_params = self.chat_params["chat_table"]
  
      text_col = t_params["text_col"]
      username_col = t_params["username_col"]
      time_col = t_params["time_col"]
  
      ast_query = Select(
          targets=[
              Identifier(text_col),
              Identifier(username_col),
              Identifier(time_col),
          ],
          from_table=Identifier(t_params["name"]),
          where=BinaryOperation(
              op="=",
              args=[
                  Identifier(t_params["chat_id_col"]),
                  Constant(chat_id),
              ],
          ),
          order_by=[OrderBy(Identifier(time_col))],
          limit=Constant(self.MAX_DEPTH),
      )
  
      resp = self.chat_task.chat_handler.query(ast_query)
      if resp.data_frame is None:
          return
  
      df = resp.data_frame
  
      # get last messages
      df = df.iloc[-self.MAX_DEPTH :]
  
      result = []
      for _, rec in df.iterrows():
          chatbot_message = ChatBotMessage(
              ChatBotMessage.Type.DIRECT,
              rec[text_col],
              user=rec[username_col],
              sent_at=rec[time_col],
          )
          result.append(chatbot_message)
  
      return result
  
imports: from mindsdb_sql.parser.ast import Identifier, Select, BinaryOperation, Constant, OrderBy
  from mindsdb.interfaces.storage import db
  from .types import ChatBotMessage
label_desc: Use image node_id 2 for calling the HandlerMemory obj's underlying member method code with example usage: obj._get_chat_history(chat_id) and returns: result