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

Method execute

pymysql/cursors.py:149–171  ·  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

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