Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64766
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'error:': 0.07; 'tries': 0.07; 'string': 0.09; 'cursor': 0.09; 'lookup': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; '__future__': 0.16; 'code),': 0.16; 'fail,': 0.16; 'files")': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'sqlite': 0.16; 'index': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'header:X-Complaints-To:1': 0.27; 'database,': 0.30; 'statement': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; 'ball': 0.31; 'open': 0.33; 'says': 0.33; 'beginning': 0.33; 'created': 0.35; 'but': 0.35; 'keyword': 0.36; 'module.': 0.36; 'next': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'easy': 0.60; 'subject:Can': 0.60; 'more': 0.64; 'here': 0.66; 'information:': 0.72; 'cut': 0.74; 'subject:get': 0.81 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Can't get sqlite3.Row working: keyword lookup doesn't work |
| Date | Sun, 26 Jan 2014 09:05:25 +0100 |
| Organization | None |
| References | <52e46bf3$0$2378$426a34cc@news.free.fr> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084808c.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| 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.5990.1390723532.18130.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390723532 news.xs4all.nl 2897 [2001:888:2000:d::a6]:36551 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64766 |
Show key headers only | View raw
lgabiot wrote:
> using Python 2.7.6
>
> I try to access a sqlite database using keyword lookup instead of
> position (much more easy to maintain code), but it always fail, with the
> error:
> Index must be int or string
>
> I have created the database, populated it, and here is the code that
> tries to retrieve the information:
>
> with sqlite3.connect(mydbPath) as db: # open the database
> db.row_factory = sqlite3.Row
> cursor = db.cursor()
> cursor.execute("SELECT * FROM files")
>
> for row in cursor.fetchall():
> print(row.keys())
> print(row["filename"])
>
>
> result is:
>
> ['filename', 'filepath', 'filetag', 'PROJECT', 'SCENE', 'TAKE', 'TAPE',
[...]
> 'is_cantar', 'is_sound_devices', 'exist']
>
> error => Index must be int or string
Please remember to cut and past the traceback next time.
> What is wrong?
My crystal ball says that you have a
from __future__ import unicode_literals
statement at the beginning of the module. If I'm right try
row[b"filename"]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can't get sqlite3.Row working: keyword lookup doesn't work lgabiot <lgabiot@hotmail.com> - 2014-01-26 02:59 +0100
Re: Can't get sqlite3.Row working: keyword lookup doesn't work Peter Otten <__peter__@web.de> - 2014-01-26 09:05 +0100
Re: Can't get sqlite3.Row working: keyword lookup doesn't work lgabiot <lgabiot@hotmail.com> - 2014-01-26 15:29 +0100
Re: Can't get sqlite3.Row working: keyword lookup doesn't work lgabiot <laurent.gabiot@gmail.com> - 2014-01-26 15:29 +0100
csiph-web