Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91179
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.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 | <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.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'attributes': 0.07; 'objects,': 0.07; 'table.': 0.07; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'res': 0.09; 'example:': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sqlalchemy': 0.16; '>>>': 0.20; 'student': 0.20; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'chris': 0.26; 'equivalent': 0.27; 'asked': 0.28; 'objects': 0.29; 'table': 0.32; 'drop': 0.35; 'to:addr:python-list': 0.35; 'list': 0.35; 'but': 0.36; 'two': 0.37; 'subject:: ': 0.37; 'received:org': 0.38; 'doing': 0.38; 'to:addr:python.org': 0.39; 'entire': 0.61; 'che': 0.63; 'quello': 0.84; 'subject:good': 0.84; 'subject:tool': 0.84; 'quando': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Lele Gaifax <lele@metapensiero.it> |
| Subject | Re: Camelot a good tool for me |
| Date | Sun, 24 May 2015 15:28:07 +0200 |
| Organization | Nautilus Entertainments |
| References | <87fv6ol93p.fsf@nautilus.nautilus> <20150522224229.GA62222@cskk.homeip.net> <CAPTjJmpCuhqTwkxfCW48e8We=9Hp7UG3EeOiynH1nNy_LjnsZw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | 151.62.69.113 |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux) |
| Cancel-Lock | sha1:C3u9nYv6Q/YGNEHxRU555a0Fizs= |
| 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.17.1432474106.5151.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1432474106 news.xs4all.nl 2953 [2001:888:2000:d::a6]:52587 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91179 |
Show key headers only | View raw
Chris Angelico <rosuav@gmail.com> writes:
> You don't automatically get nice objects with attributes named after
> columns, but neither will SQLAlchemy unless you're doing the
> equivalent of "select * from". Example:
>
>>>> session.query(Student).all()
> [<__main__.Student object at 0x7fc2de3fc290>, <__main__.Student object
> at 0x7fc2de3fc350>, <__main__.Student object at 0x7fc2de3fc3d0>]
>
> That's a list of Student objects, because I asked for the entire table.
>
>>>> session.query(Student.name, Student.year).all()
> [(u'Fred', 2015), (u'Joe', 2015), (u"Robert'); DROP TABLE Students;--", 2012)]
>
> That's a list of tuples, because I asked for just two columns.
Wrong:
>>> res = session.query(Student.name, Student.year).all()
>>> type(res)
<class 'list'>
>>> type(res[0])
<class 'sqlalchemy.util._collections.result'>
>>> type(res[0].name)
<class 'str'>
>>> type(res[0][0])
<class 'str'>
>>> res[0].name == res[0][0]
True
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it | -- Fortunato Depero, 1929.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Camelot a good tool for me Lele Gaifax <lele@metapensiero.it> - 2015-05-24 15:28 +0200
csiph-web