code: def on_connect(self):
      extras = self._psycopg2_extras
  
      fns = []
      if self.client_encoding is not None:
  
          def on_connect(dbapi_conn):
              dbapi_conn.set_client_encoding(self.client_encoding)
  
          fns.append(on_connect)
  
      if self.dbapi:
  
          def on_connect(dbapi_conn):
              extras.register_uuid(None, dbapi_conn)
  
          fns.append(on_connect)
  
      if self.dbapi and self.use_native_hstore:
  
          def on_connect(dbapi_conn):
              hstore_oids = self._hstore_oids(dbapi_conn)
              if hstore_oids is not None:
                  oid, array_oid = hstore_oids
                  kw = {"oid": oid}
                  kw["array_oid"] = array_oid
                  extras.register_hstore(dbapi_conn, **kw)
  
          fns.append(on_connect)
  
      if self.dbapi and self._json_deserializer:
  
          def on_connect(dbapi_conn):
              extras.register_default_json(
                  dbapi_conn, loads=self._json_deserializer
              )
              extras.register_default_jsonb(
                  dbapi_conn, loads=self._json_deserializer
              )
  
          fns.append(on_connect)
  
      if fns:
  
          def on_connect(dbapi_conn):
              for fn in fns:
                  fn(dbapi_conn)
  
          return on_connect
      else:
          return None
  
imports: from __future__ import annotations
  import collections.abc
  import logging
  import re
  from typing import cast
  from .None import ranges
  from ._psycopg_common import _PGDialect_common_psycopg
  from ._psycopg_common import _PGExecutionContext_common_psycopg
  from .base import PGIdentifierPreparer
  from .json import JSON
  from .json import JSONB
  from ...None import types
  from ...None import util
  from ...util import FastIntFlag
  from ...util import parse_user_argument_for_enum
label_desc: Use image node_id 12 for calling the PGDialect_psycopg2 obj's underlying member method code with example usage: obj.on_connect() and returns: on_connect, None