Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64594
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: sqlite3 docbug (was problem with sqlite3) |
| Date | 2014-01-23 05:43 -0500 |
| References | <52e07f45$0$3631$426a34cc@news.free.fr> <mailman.5864.1390446316.18130.python-list@python.org> <d8243c7c-8d9c-4ef6-8842-2fe856633a4e@googlegroups.com> <mailman.5870.1390452106.18130.python-list@python.org> <1f13ee0c-5cb5-4627-9f38-2058a8235083@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5881.1390473818.18130.python-list@python.org> (permalink) |
On 1/23/2014 12:35 AM, Rustom Mody wrote:
> On Thursday, January 23, 2014 10:11:42 AM UTC+5:30, Chris Angelico wrote:
>> I think it's fairly clear from the example that it has to be either a
>> tuple or a dict. Looks fine to me.
>
> yes 'from the example' and only from there!
'parameters' is a single parameter, which could be called 'seq_dict'.
Let(seq_dict) must equal the number of replacements. A dict with extra
pairs raises.
A list instead of a tuple does work, but not an iterable, so 'sequence'.
A dict subclass works, but a UserDict is treated as a sequence.
-----------
import sqlite3
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("create table people (name_last, age)")
who = "Yeltsin"
age = 72
s = (who, age)
d = {'who':who, 'age':age}
class D(dict): pass
dD = D(d)
from collections import UserDict
dU = UserDict(d)
# This is the qmark style:
cur.execute("insert into people values (?, ?)", s)
# And this is the named style:
cur.execute("select * from people where name_last=:who and age=:age", dU)
print(cur.fetchone())
--------------
>>>
Traceback (most recent call last):
File "C:\Programs\Python34\tem.py", line 23, in <module>
cur.execute("select * from people where name_last=:who and
age=:age", dU)
File "C:\Programs\Python34\lib\collections\__init__.py", line 883, in
__getitem__
raise KeyError(key)
KeyError: 0
Replacing dU in the last call with s works!
http://bugs.python.org/issue20364
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
problem with sqlite3: cannot use < in a SQL query with (?) lgabiot <lgabiot@hotmail.com> - 2014-01-23 03:32 +0100
Re: problem with sqlite3: cannot use < in a SQL query with (?) lgabiot <lgabiot@hotmail.com> - 2014-01-23 03:34 +0100
Re: problem with sqlite3: cannot use < in a SQL query with (?) Chris Angelico <rosuav@gmail.com> - 2014-01-23 13:42 +1100
Re: problem with sqlite3: cannot use < in a SQL query with (?) bob gailer <bgailer@gmail.com> - 2014-01-22 21:51 -0500
Re: problem with sqlite3: cannot use < in a SQL query with (?) bob gailer <bgailer@gmail.com> - 2014-01-22 21:51 -0500
Re: problem with sqlite3: cannot use < in a SQL query with (?) Tim Chase <python.list@tim.thechases.com> - 2014-01-22 21:05 -0600
sqlite3 docbug (was problem with sqlite3) Rustom Mody <rustompmody@gmail.com> - 2014-01-22 20:33 -0800
Re: sqlite3 docbug (was problem with sqlite3) Rustom Mody <rustompmody@gmail.com> - 2014-01-22 20:37 -0800
Re: sqlite3 docbug (was problem with sqlite3) Chris Angelico <rosuav@gmail.com> - 2014-01-23 15:41 +1100
Re: sqlite3 docbug (was problem with sqlite3) Rustom Mody <rustompmody@gmail.com> - 2014-01-22 21:35 -0800
Re: sqlite3 docbug (was problem with sqlite3) Chris Angelico <rosuav@gmail.com> - 2014-01-23 16:42 +1100
Re: sqlite3 docbug (was problem with sqlite3) lgabiot <lgabiot@hotmail.com> - 2014-01-23 08:37 +0100
Re: sqlite3 docbug (was problem with sqlite3) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-23 09:04 +0000
Re: sqlite3 docbug (was problem with sqlite3) lgabiot <lgabiot@hotmail.com> - 2014-01-23 10:45 +0100
Re: sqlite3 docbug (was problem with sqlite3) Rustom Mody <rustompmody@gmail.com> - 2014-01-23 02:23 -0800
Re: sqlite3 docbug (was problem with sqlite3) lgabiot <laurent.gabiot@gmail.com> - 2014-01-23 10:45 +0100
Re: sqlite3 docbug (was problem with sqlite3) lgabiot <laurent.gabiot@gmail.com> - 2014-01-23 08:37 +0100
Re: sqlite3 docbug (was problem with sqlite3) Terry Reedy <tjreedy@udel.edu> - 2014-01-23 05:43 -0500
Re: sqlite3 docbug (was problem with sqlite3) Rustom Mody <rustompmody@gmail.com> - 2014-01-23 07:00 -0800
Re: sqlite3 docbug (was problem with sqlite3) Tim Chase <python.list@tim.thechases.com> - 2014-01-23 06:36 -0600
Re: sqlite3 docbug (was problem with sqlite3) Terry Reedy <tjreedy@udel.edu> - 2014-01-23 20:03 -0500
Re: sqlite3 docbug (was problem with sqlite3) Asaf Las <roegltd@gmail.com> - 2014-01-22 23:18 -0800
Re: sqlite3 docbug (was problem with sqlite3) Chris Angelico <rosuav@gmail.com> - 2014-01-23 18:47 +1100
csiph-web