code: def install_extension(conn, extension: str):
      
  
      query = 'CREATE EXTENSION IF NOT EXISTS "%s";'
  
      with conn.cursor() as cursor:
          cursor.execute(query, (AsIs(extension),))
  
      installed = check_extension(conn, extension)
  
      if not installed:
          raise psycopg2.ProgrammingError(
              'Postgres extension failed installation.', extension
          )
docs: Install Postgres extension.