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


Groups > comp.lang.python > #95528

Re: Every character of a string becomes a binding

Path csiph.com!news.mixmin.net!news2.arglkargh.de!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <zachary.ware@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; '21,': 0.07; 'cc:addr:python-list': 0.09; 'bindings': 0.09; 'here?': 0.09; 'incorrect': 0.09; 'subject:string': 0.09; '52,': 0.16; "?',": 0.16; 'binding,': 0.16; 'expects': 0.16; 'sequence,': 0.16; 'sequence:': 0.16; 'wrote:': 0.16; 'string': 0.17; 'sender:addr:gmail.com': 0.18; 'skip:` 10': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'pass': 0.22; 'am,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'character': 0.29; 'statement': 0.32; 'traceback': 0.33; 'wrap': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'urls': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'method': 0.37; 'means': 0.39; 'why': 0.39; 'where': 0.40; 'skip:u 10': 0.61; 'binding': 0.66; 'cecil': 0.84; 'westerhof': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=p/XfNN43dCcnjrpBbRW5pAZ95a4Q0Kx+K6JxCJGu9Rs=; b=1IYfVVNnfTnnUKonIDY3USPlTuIOjkEMYMF5ZiHA35sM91l2vhSkEK6Zm17jBo5eYR 2f87foTkBw9AaYH/x369ZPNO9hM/WYxSa3ntCXkTkJSW2YZYB5afB5LW12nB8Y6ggvyO Yqpu5JVUkSfYnbIO+LBuj6Pr0/D4av4pPY0CvolN2BfQVUT7PKNuZUroYGWe5Ia7u33b XPAxvzV4c9+a41Er6rWYhu2/szkefmcG8DycsMVzbx1CAyLUxN1if96I5pv+3xgIKFPM NSw3HjpLVQt4SWg2IbWE8qrzdl6l96aiZ7uNgXptd8F6IwgVnvZnILG8kSJs5XjRU2Jp WEuQ==
X-Received by 10.50.41.67 with SMTP id d3mr3314317igl.57.1440175838877; Fri, 21 Aug 2015 09:50:38 -0700 (PDT)
MIME-Version 1.0
Sender zachary.ware@gmail.com
In-Reply-To <871tewppdr.fsf@Equus.decebal.nl>
References <871tewppdr.fsf@Equus.decebal.nl>
From Zachary Ware <zachary.ware+pylist@gmail.com>
Date Fri, 21 Aug 2015 11:50:19 -0500
X-Google-Sender-Auth PMUob_hyWKmstRSB68awihN4-uc
Subject Re: Every character of a string becomes a binding
To Cecil Westerhof <Cecil@decebal.nl>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.0.1440175848.17298.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1440175848 news.xs4all.nl 23831 [2001:888:2000:d::a6]:49323
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95528

Show key headers only | View raw


On Fri, Aug 21, 2015 at 11:39 AM, Cecil Westerhof <Cecil@decebal.nl> wrote:
> I have the following with sqlite3:
> urls = c.execute('SELECT URL FROM LINKS WHERE URL = ?', url).fetchall()
>
> But this gives:
> Traceback (most recent call last):
>   File "./createDB.py", line 52, in <module>
>     urls = c.execute('SELECT URL FROM LINKS WHERE URL = ?', url).fetchall()
> sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 40 supplied.
>
> The number of bindings is the length of the string.
> What is happening here? Why is every character of the string seen as a
> binding, instead of the string being the binding?

Because the execute method expects the bindings to be passed as a
sequence, which means to pass a single binding you need to wrap it in
a sequence: `c.execute('SELECT url FROM links WHERE url = ?', (url,))`

-- 
Zach

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


Thread

Every character of a string becomes a binding Cecil Westerhof <Cecil@decebal.nl> - 2015-08-21 18:39 +0200
  Re: Every character of a string becomes a binding Zachary Ware <zachary.ware+pylist@gmail.com> - 2015-08-21 11:50 -0500
    Re: Every character of a string becomes a binding Cecil Westerhof <Cecil@decebal.nl> - 2015-08-21 19:04 +0200
      Re: Every character of a string becomes a binding Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-08-22 11:45 +0200
  Re: Every character of a string becomes a binding John Gordon <gordon@panix.com> - 2015-08-21 17:02 +0000
  Re: Every character of a string becomes a binding Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-08-21 20:47 -0400
  Re: Every character of a string becomes a binding Chris Angelico <rosuav@gmail.com> - 2015-08-22 11:03 +1000

csiph-web