code: def mogrify(self, query, *parameters, **kwargs):
          
          cursor = self._cursor()
          try:
              if kwargs:
                  res = cursor.mogrify(query % dict([(r[0], adapt(r[1])) for r in list(kwargs.items())]))
              else:
                  res = cursor.mogrify(query, parameters)
  
              cursor.close()
              return res
  
          except:  # pragma: no cover
              cursor.close()
              raise
docs: From http://initd.org/psycopg/docs/cursor.html?highlight=mogrify#cursor.mogrify
          Return a query string after arguments binding.
          The string returned is exactly the one that would be sent to the database running
          the execute() method or similar.