Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68299

DB API question - where is a stored procedure's return value?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'yet.': 0.04; 'argument': 0.05; 'output': 0.05; 'modified': 0.07; '(those': 0.09; 'currently,': 0.09; 'cursor': 0.09; 'defines': 0.09; 'iterate': 0.09; 'method,': 0.09; 'parameter': 0.09; 'pep': 0.09; 'subject:question': 0.10; 'api': 0.11; 'python': 0.11; 'stored': 0.12; '"modified': 0.16; 'dictionary),': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'optional': 0.16; 'rewritten': 0.16; 'sequence.': 0.16; 'stored.': 0.16; 'stumbled': 0.16; 'subject:API': 0.16; 'subject:where': 0.16; 'values?': 0.16; '{})': 0.16; 'all.': 0.16; 'sender:addr:gmail.com': 0.17; 'module': 0.19; 'value.': 0.19; 'input': 0.22; 'module,': 0.24; 'skip': 0.24; "haven't": 0.24; "i've": 0.25; 'mention': 0.26; 'possibly': 0.26; 'this:': 0.26; 'values': 0.27; '(this': 0.29; "doesn't": 0.30; 'returned': 0.30; 'sets': 0.30; 'specified': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'concern': 0.31; 'procedures.': 0.31; 'values.': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'problem': 0.35; 'received:google.com': 0.35; 'module.': 0.36; 'sequence': 0.36; 'set.': 0.36; 'entry': 0.36; 'method': 0.36; 'subject:?': 0.36; 'clear': 0.37; 'handle': 0.38; 'to:addr:python-list': 0.38; 'ability': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'new': 0.61; 'first': 0.61; 'such': 0.63; 'provide': 0.64; 'more': 0.64; 'chance': 0.65; 'status:': 0.68; 'saw': 0.77; 'received:mail-ob0-x22f.google.com': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=r3GNXUD2eJ2Nl6SNAh95laNpiA/kU9SHQ20TSc9vrFU=; b=XNT9SSVLxEyNQs1TMT57kq5RP8PINBjOmpFWnaTjCmr80WFZLcATCijzIqL3yx2XPU ILy+GCYojmRbeX1FflbF/YH+FAYGE2lES1TjAlDLiT77jKHFs37GNodhBK1kKrUzyDQL /+W4D0rNmbaiv8iE9CDaZxsav4RqU7A9RmRqpA22CitTq9IcG760ilt9dZmD7DfPRXOv KFkU1zA/bdRgpCfr2dgUjpBx1L751KoyMSf108TObBxRxe+47Jgo1eUa9bYEmsypbaOu wnvfsbCU1l4tswkK5raJy0kcSDTZzzL9yWhpXiND963C0hBVQneABoXryltPgDcSRkvM 7iTg==
MIME-Version 1.0
X-Received by 10.182.72.234 with SMTP id g10mr40423728obv.21.1394660647472; Wed, 12 Mar 2014 14:44:07 -0700 (PDT)
Sender skip.montanaro@gmail.com
Date Wed, 12 Mar 2014 16:44:07 -0500
X-Google-Sender-Auth Ksop1DUa6kqYt8dJ2172_3ACpt8
Subject DB API question - where is a stored procedure's return value?
From Skip Montanaro <skip@pobox.com>
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8105.1394660650.18130.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394660650 news.xs4all.nl 2960 [2001:888:2000:d::a6]:45172
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68299

Show key headers only | View raw


I've stumbled on a problem with the python-sybase module. If I have a
stored procedure like this:

create stored procedure test_proc
as
    return 1

and call it from Python like this:

curs.callproc("test_proc", {})

it's not clear to me where the return status is stored. Currently, the
python-sybase module provides (I believe) the ability to set output
parameters (those specified as such in the argument dictionary), and
you can iterate over all the result sets the stored procedure
produces.

Looking at the Python database API (PEP 249), I saw no mention of the
return status:

.callproc( procname [, parameters ] )

(This method is optional since not all databases provide stored procedures. [3])

Call a stored database procedure with the given name. The sequence of
parameters must contain one entry for each argument that the procedure
expects. The result of the call is returned as modified copy of the
input sequence. Input parameters are left untouched, output and
input/output parameters replaced with possibly new values.

The procedure may also provide a result set as output. This must then
be made available through the standard.fetch*() methods.

I see no mention of how to handle the return value. The "modified copy
of the input sequence" is just that. In the case of the python-sybase
module, any parameter values in the input dictionary  of type
DataBufType are rewritten with values from the first row of the first
result set. The Cursor class also defines a _status_result() method,
which sounds promising. I haven't had a chance to try it out yet. My
concern is more that the Python database API doesn't mention stored
procedure return values at all.

What do other database adaptors do about stored procedure return
values? Does PEP 249 need revision?

Skip

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

DB API question - where is a stored procedure's return value? Skip Montanaro <skip@pobox.com> - 2014-03-12 16:44 -0500

csiph-web