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

Method execute

pymysql/cursors.py:150–172  ·  view source on GitHub ↗

Execute a query. :param query: Query to execute. :type query: str :param args: Parameters used with query. (optional) :type args: tuple, list or dict :return: Number of affected rows. :rtype: int If args is a list or tuple, %s can be used a

(self, query, args=None)

Source from the content-addressed store, hash-verified

148 return self._mogrify(query, args)
149
150 def execute(self, query, args=None):
151 """Execute a query.
152
153 :param query: Query to execute.
154 :type query: str
155
156 :param args: Parameters used with query. (optional)
157 :type args: tuple, list or dict
158
159 :return: Number of affected rows.
160 :rtype: int
161
162 If args is a list or tuple, %s can be used as a placeholder in the query.
163 If args is a dict, %(name)s can be used as a placeholder in the query.
164 """
165 while self.nextset():
166 pass
167
168 if args is not None:
169 query = self._mogrify(query, args)
170 result = self._query(query)
171 self._executed = query
172 return result
173
174 def executemany(self, query, args):
175 """Run several data against one query.

Callers 15

executemanyMethod · 0.95
_do_execute_manyMethod · 0.95
connectMethod · 0.80
__init__Method · 0.80
__exit__Method · 0.80
TestAuthenticationClass · 0.80
test_pluginMethod · 0.80
realTestPamAuthMethod · 0.80

Calls 3

nextsetMethod · 0.95
_mogrifyMethod · 0.95
_queryMethod · 0.95

Tested by 15

__init__Method · 0.64
__exit__Method · 0.64
test_pluginMethod · 0.64
realTestPamAuthMethod · 0.64
testAuthSHA256Method · 0.64
testAuthEd25519Method · 0.64
test_largedataMethod · 0.64