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


Groups > comp.lang.python > #16070

Re: sqlalchemy beginner

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; ':-)': 0.06; 'received:edu.au': 0.07; 'removes': 0.07; 'sql.': 0.07; 'statements,': 0.07; 'python': 0.08; 'manipulate': 0.09; 'orm': 0.09; 'python-level': 0.09; 'seriously.': 0.09; 'subject:beginner': 0.09; 'talks': 0.10; 'alex23': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'notation,': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'roy': 0.16; 'sane': 0.16; 'sqlalchemy': 0.16; 'sqlalchemy,': 0.16; 'wizard,': 0.16; 'cc:addr:python-list': 0.16; 'syntax': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'cheers,': 0.20; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'knowing': 0.23; 'figure': 0.23; 'calls.': 0.23; 'cc:2**0': 0.24; 'there.': 0.24; 'happening': 0.24; 'classes': 0.26; "i'm": 0.26; 'all,': 0.28; 'do.': 0.28; 'expressions': 0.29; 'mapping': 0.29; 'worked': 0.29; 'cc:addr:python.org': 0.29; 'nov': 0.29; 'seem': 0.30; '22,': 0.30; 'translate': 0.31; "i've": 0.31; 'does': 0.32; 'objects': 0.32; 'header:User-Agent:1': 0.33; 'mostly': 0.34; 'anything': 0.34; 'backend': 0.34; 'emphasis': 0.34; 'received:au': 0.36; 'charset:us-ascii': 0.37; 'but': 0.37; 'run': 0.37; "there's": 0.37; 'enough': 0.38; 'put': 0.38; 'i.e.': 0.39; "it's": 0.40; '(1)': 0.40; 'more': 0.61; 'worth': 0.61; 'cost': 0.63; 'direction.': 0.64; 'received:202': 0.66; 'wish': 0.70; 'cameron': 0.73; 'article': 0.74; '(make': 0.84; 'calvin': 0.84; 'or:': 0.91
Date Tue, 22 Nov 2011 17:06:16 +1100
From Cameron Simpson <cs@zip.com.au>
To Roy Smith <roy@panix.com>
Subject Re: sqlalchemy beginner
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <roy-F87DE4.22180421112011@news.panix.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <roy-F87DE4.22180421112011@news.panix.com>
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2943.1321942466.27778.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1321942466 news.xs4all.nl 6906 [2001:888:2000:d::a6]:50571
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16070

Show key headers only | View raw


On 21Nov2011 22:18, Roy Smith <roy@panix.com> wrote:
| In article 
| <8832ab6d-8def-45d1-92df-baac40e1c498@t36g2000prt.googlegroups.com>,
|  alex23 <wuwei23@gmail.com> wrote:
| > On Nov 22, 10:25?am, Roy Smith <r...@panix.com> wrote:
| > > Everytime I've worked with SQLAlchemy, I've run away screaming in the
| > > other direction. ?Sure, portability is a good thing, but at what cost?
| > 
| > I've never found SQLAlchemy to be anything but sane and approachable.
| > It's really worth understanding _how_ it works so you can see there's
| > no magic happening there.
| > 
| > What cost do you see inherit in the use of SQLAlchemy?
| 
| The cost of understanding how it works :-)
| 
| Seriously.  I understand SQL.  Well, I'm not a SQL wizard, but I 
| understand enough to do what I need to do.  Whenever I have to use 
| SQLAlchemy, I always find myself knowing exactly what SQL I want to 
| write and scratching my head to figure out how to translate that into 
| SQLAlchemy calls.

Are you trying to go the ORM route (make classes etc mapping to SQL
entities etc)?

I ask because I avoid ORM and mostly use the SQL syntax notation, eg:

    for node_id, attr, value in select( [ attrs.c.NODE_ID,
                                          attrs.c.ATTR,
                                          attrs.c.VALUE,
                                        ] ) \
                                .order_by(asc(attrs.c.NODE_ID)) \
                                .execute():

or:

    self.attrs.delete(self.attrs.c.NODE_ID == node_id).execute()

which I find very easy to read (self.attrs is an SQLAchemy table).

ORMs seem very cool and all, but I personally prefer to work with simple
SQL level schemae and python-level objects and classes i.e. not ORM
classes but ordinary classes that cll SQLAlchemy
select/update/delete/etc methods to manipulate the db.

For me the great strengths of SQLA are that it (1) talks to many
different backend DBs and (2) removes the need to write tediously quotes
SQL because I can write python expressions like the above that map
directly to SQL statements, and SQLA does all the quoting, conversion
etc. Reliably!

Cheers,
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

I sometimes wish that people would put a little more emphasis upon the
observance of the law than they do upon its enforcement. - Calvin Coolidge

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


Thread

sqlalchemy beginner Jabba Laci <jabba.laci@gmail.com> - 2011-11-21 16:56 +0100
  Re: sqlalchemy beginner John Gordon <gordon@panix.com> - 2011-11-21 17:08 +0000
  Re: sqlalchemy beginner Roy Smith <roy@panix.com> - 2011-11-21 19:25 -0500
    Re: sqlalchemy beginner alex23 <wuwei23@gmail.com> - 2011-11-21 18:51 -0800
      Re: sqlalchemy beginner Roy Smith <roy@panix.com> - 2011-11-21 22:18 -0500
        Re: sqlalchemy beginner Cameron Simpson <cs@zip.com.au> - 2011-11-22 17:06 +1100

csiph-web