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


Groups > comp.lang.python > #65262

Re: mapping objects

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rmorgan466@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'xml,': 0.05; 'json': 0.07; 'sql.': 0.07; 'assuming': 0.09; 'facts': 0.09; 'orm': 0.09; 'parsing': 0.09; 'cc:addr:python-list': 0.11; 'stored': 0.12; 'caliber': 0.16; 'csv,': 0.16; 'objects?': 0.16; 'presume': 0.16; 'simpson': 0.16; 'sqlalchemy': 0.16; 'storing': 0.16; 'stumbled': 0.16; 'sure.': 0.16; 'unlocked': 0.16; 'xml),': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'backend': 0.19; 'work,': 0.20; 'seems': 0.21; 'feb': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'basis,': 0.24; 'beauty': 0.24; 'regardless': 0.24; 'cheers,': 0.24; '(or': 0.24; '---': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; 'first,': 0.26; 'tables': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'correct': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'serve': 0.31; 'loading': 0.31; 'stuff': 0.32; 'url:python': 0.33; 'could': 0.34; 'anywhere': 0.35; 'convert': 0.35; 'objects': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'representing': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'method': 0.36; 'thanks': 0.36; 'possible': 0.36; 'url:org': 0.36; 'example,': 0.37; 'so,': 0.37; 'two': 0.37; 'actions': 0.38; 'filter': 0.38; 'ability': 0.39; 'skip:& 20': 0.39; 'does': 0.39; 'url:mail': 0.40; 'easy': 0.60; 'director': 0.61; "you're": 0.61; "you've": 0.63; 'information': 0.63; 'provide': 0.64; 'more': 0.64; 'sports': 0.69; 'academy': 0.74; 'cut': 0.74; 'special': 0.74; 'bare': 0.84; 'dialect': 0.84; 'rita': 0.84; 'theft': 0.84; 'url:sqlalchemy': 0.84; 'feet': 0.93; 'army': 0.95; 'directly.': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jU2r/BW8ydINOPp6DKPVNe7YFQyQ/fa4y3eywgWCgM8=; b=xQNygJ1oDxzDUSwjSVicJ4AmDQuls1JMOfTAjrmv4OLuQmmp+mLRC5J5DOrDo+SBXQ 4xjkBgVBVP2RogssL1MEBLe19rFZD/cjR8CKonvSelM0/ONDwKUjGEc8tFVMIBBlHkQI KASwZVGIcx7hKbesbHagwsKD+glC5wOfQA5ZzRKzG773w43IDSOnqcQ2vMNyzoWk4+ki cbSLuG2rft0YC4nqzQa0VBlX5BJBnglPzEp+zHJkg7aAt0BcQ4dDMJQRoCq1LRgXRf1n ws5rygXwWPYQXVjEXXF/KnyU5ZfIFPbwAiIuvzkWvOWxXzvFm27wNkkptq1d6saphCep HBsA==
MIME-Version 1.0
X-Received by 10.182.126.225 with SMTP id nb1mr898905obb.48.1391344919538; Sun, 02 Feb 2014 04:41:59 -0800 (PST)
In-Reply-To <20140202065809.GA4704@cskk.homeip.net>
References <CAOF-KfgfZrFc0cQ7f5XpgWP4fjwVpuNsV6h+aoMUvob-V7AcHQ@mail.gmail.com> <20140202065809.GA4704@cskk.homeip.net>
Date Sun, 2 Feb 2014 07:41:59 -0500
Subject Re: mapping objects
From Rita <rmorgan466@gmail.com>
To Cameron Simpson <cs@zip.com.au>
Content-Type multipart/alternative; boundary=089e01537c86b0717404f16bbb7c
Cc "python-list@python.org" <python-list@python.org>
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.6306.1391345257.18130.python-list@python.org> (permalink)
Lines 166
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391345257 news.xs4all.nl 2903 [2001:888:2000:d::a6]:44683
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65262

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Thanks for the response Cameron. No amount of 'googling' could provide me
with that caliber response :-)

So, it seems regardless I would need a database.





On Sun, Feb 2, 2014 at 1:58 AM, Cameron Simpson <cs@zip.com.au> wrote:

> On 01Feb2014 20:46, Rita <rmorgan466@gmail.com> wrote:
> > I want to learn more about ORMs so I stumbled upon, SqlAlchemy.
> >
> > If i had a JSON document (or XML, CSV, etc.._) is it possible to convert
> it
> > to a SQLAlchemy objects? I like the ability to query/filter (
> >
> http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#common-filter-operators
> )
> >  the
> > data assuming I set up the proper schema.
>
> Well, not as directly as you might hope. As I recall, SQLAlchemy
> ORMs provide an easy way to make objects representing database
> entities and whose methods automatically drive the necessary SQL
> actions to manipulate them.
>
> On that basis, you won't get anywhere without loading up the
> JSON/XML/etc, parsing it for relevant information (trivial with
> CSV, less so for structured data like JSON or XML), and storing it
> in a database. To which you then point SQLAlchemy.
>
> So you're already doing the fiddly bit just to get stuff into the database.
>
> The neat filter operations you cite are actually done by special
> methods on the objects representing tables and columns. For example,
>
>   User.name == None
>
> is done via the __eq__ method of "User.name". And they return
> strings: bare SQL. The beauty of this is that one can write almost
> idiomatic python, and SQLA will generate correct SQL in the right
> dialect for the database backend, and with all the values correctly
> escaped.
>
> However, it does presume you _already_ have a backend that can be
> queried with SQL.
>
> > Also, is this a valid way to use an ORM suite?
>
> Well, in principle sure. But SQLA won't do it for you directly. It really
> is for data already stored in an SQL queriable database.
>
> Your point about using SQLA's filter operations is right, _provided_
> you have already loaded the original data into a database with the
> right schema. If you've done that work, then SQLA may well serve
> you well from that point on.
>
> Cheers,
> --
> Cameron Simpson <cs@zip.com.au>
>
> We knew Army cadets were involved because they cut through two fences
> to get to the goats, and 15 feet away there was an unlocked gate.
>         - a director of sports information in the Navy, regarding the theft
>           of some mascots from the Naval Academy by Army rivals
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
--- Get your facts first, then you can distort them as you please.--

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


Thread

Re: mapping objects Rita <rmorgan466@gmail.com> - 2014-02-02 07:41 -0500

csiph-web