MCPcopy Index your code
hub / github.com/davispuh/MySQL-for-Python-3 / callproc

Method callproc

MySQLdb/cursors.py:268–314  ·  view source on GitHub ↗

Execute stored procedure procname with args procname -- string, name of procedure to execute on server args -- Sequence of parameters to use with procedure Returns the original args. Compatibility warning: PEP-249 specifies that any modified parame

(self, procname, args=())

Source from the content-addressed store, hash-verified

266 return r
267
268 def callproc(self, procname, args=()):
269
270 """Execute stored procedure procname with args
271
272 procname -- string, name of procedure to execute on server
273
274 args -- Sequence of parameters to use with procedure
275
276 Returns the original args.
277
278 Compatibility warning: PEP-249 specifies that any modified
279 parameters must be returned. This is currently impossible
280 as they are only available by storing them in a server
281 variable and then retrieved by a query. Since stored
282 procedures return zero or more result sets, there is no
283 reliable way to get at OUT or INOUT parameters via callproc.
284 The server variables are named @_procname_n, where procname
285 is the parameter above and n is the position of the parameter
286 (from zero). Once all result sets generated by the procedure
287 have been fetched, you can issue a SELECT @_procname_0, ...
288 query using .execute() to get any OUT or INOUT values.
289
290 Compatibility warning: The act of calling a stored procedure
291 itself creates an empty result set. This appears after any
292 result sets generated by the procedure. This is non-standard
293 behavior with respect to the DB-API. Be sure to use nextset()
294 to advance through all result sets; otherwise you may get
295 disconnected.
296 """
297
298 db = self._get_db()
299 charset = db.character_set_name()
300 for index, arg in enumerate(args):
301 q = "SET @_{!s}_{:d}={!s}".format(procname, index, db.literal(arg))
302 if isinstance(q, str):
303 q = q.encode(charset)
304 self._query(q)
305 self.nextset()
306
307 q = "CALL {!s}({!s})".format(procname, ','.join(['@_{!s}_{:d}'.format(procname, i)
308 for i in range(len(args))]))
309 if type(q) is str:
310 q = q.encode(charset)
311 self._query(q)
312 self._executed = q
313 if not self._defer_warnings: self._warning_check()
314 return args
315
316 def _do_query(self, q):
317 db = self._get_db()

Callers 4

test_callprocMethod · 0.80
test_nextsetMethod · 0.80
test_nextsetMethod · 0.80

Calls 5

_get_dbMethod · 0.95
_queryMethod · 0.95
nextsetMethod · 0.95
_warning_checkMethod · 0.95
literalMethod · 0.80

Tested by 4

test_callprocMethod · 0.64
test_nextsetMethod · 0.64
test_nextsetMethod · 0.64