MCPcopy Index your code
hub / github.com/PyMySQL/mysqlclient / callproc

Method callproc

src/MySQLdb/cursors.py:279–323  ·  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 parameters mus

(self, procname, args=())

Source from the content-addressed store, hash-verified

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

Callers 4

test_callprocMethod · 0.80
test_nextsetMethod · 0.80
test_nextsetMethod · 0.80

Calls 4

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

Tested by 4

test_callprocMethod · 0.64
test_nextsetMethod · 0.64
test_nextsetMethod · 0.64