MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / _mogrify

Method _mogrify

pymysql/cursors.py:107–126  ·  view source on GitHub ↗

Return query after binding args.

(self, query, args)

Source from the content-addressed store, hash-verified

105 return self._nextset(False)
106
107 def _mogrify(self, query, args) -> str:
108 """Return query after binding args."""
109 escape = self._get_db().escape
110
111 if isinstance(args, dict):
112 args = {key: escape(item) for key, item in args.items()}
113 elif isinstance(args, (list, tuple)):
114 args = tuple(map(escape, args))
115 else:
116 # Escaping a single argument is not part of the DB-API or mysqlclient.
117 # It will be removed in the next version.
118 warnings.warn(
119 "single argument is deprecated and will be removed in the next version.",
120 DeprecationWarning,
121 stacklevel=3)
122 args = escape(args)
123 try:
124 return query % args
125 except TypeError as m:
126 raise err.ProgrammingError(str(m))
127
128 def mogrify(self, query, args=None) -> str:
129 """

Callers 3

mogrifyMethod · 0.95
executeMethod · 0.95
_do_execute_manyMethod · 0.95

Calls 1

_get_dbMethod · 0.95

Tested by

no test coverage detected