code: def connect(self):
          
          connection = psycopg2.connect(
              host=self.host,
              port=self.port,
              database=self.database,
              user=self.user,
              password=self.password)
          connection.set_client_encoding('utf-8')
          return connection
docs: Get a psycopg2 connection object to the database where the table is.