Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95540
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Every character of a string becomes a binding |
| Date | 2015-08-21 20:47 -0400 |
| Organization | IISS Elusive Unicorn |
| References | <871tewppdr.fsf@Equus.decebal.nl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6.1440204449.17298.python-list@python.org> (permalink) |
On Fri, 21 Aug 2015 18:39:28 +0200, Cecil Westerhof <Cecil@decebal.nl>
declaimed the following:
>I have the following with sqlite3:
>urls = c.execute('SELECT URL FROM LINKS WHERE URL = ?', url).fetchall()
>
Well, for one complication... You are asking for the very information
you are providing...
select URL field
where the URL field is equal to some value.
What do you really expect from that? If the table has multiple records
with the same URL value, you will get multiple copies of the same URL.
>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.
So show us the code that creates "url"...
Though I suspect the problem is that "url" is an iterable, and the
DB-API expects the parameters to be provided IN an iterable.
Try using
... where URL=?', (url,) )
to make it a tuple (an iterable) with one item inside it.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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