class_docstr: This handler handles connection and execution of the PostgreSQL with pgvector extension statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","PostgreSQL","with","pgvector","extension","statements","."]
docstr: Handles the connection to a PostgreSQL database instance.
docstr_tok: ["Handles","the","connection","to","a","PostgreSQL","database","instance","."]
code: def connect(self) -> psycopg.connection:
      """
      Handles the connection to a PostgreSQL database instance.
      """
      self.connection = super().connect()
  
      with self.connection.cursor() as cur:
          try:
              # load pg_vector extension
              cur.execute("CREATE EXTENSION IF NOT EXISTS vector")
              logger.info("pg_vector extension loaded")
  
          except psycopg.Error as e:
              logger.error(
                  f"Error loading pg_vector extension, ensure you have installed it before running, {e}!"
              )
              return HandlerResponse(
                  resp_type=RESPONSE_TYPE.ERROR, error_message=str(e)
              )
  
      # register vector type with psycopg2 connection
      register_vector(self.connection)
  
      return self.connection
  
imports: from collections import OrderedDict
  from typing import List, Union
  import pandas
  import psycopg
  from mindsdb_sql import ASTNode, Parameter, Identifier, Update, BinaryOperation
  from pgvector.psycopg import register_vector
  from mindsdb.integrations.handlers.postgres_handler.postgres_handler import PostgresHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import RESPONSE_TYPE
  from mindsdb.integrations.libs.response import HandlerResponse
  from mindsdb.integrations.libs.vectordatabase_handler import FilterCondition, VectorStoreHandler
  from mindsdb.utilities import log
  from mindsdb.utilities.profiler import profiler
label_desc: Use image node_id 2 for calling the PgVectorHandler obj's underlying member method code with example usage: obj.connect() and returns: self, HandlerResponse