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


Groups > comp.lang.python > #91165

Re: Camelot a good tool for me

Date 2015-05-23 08:42 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: Camelot a good tool for me
References <87fv6ol93p.fsf@nautilus.nautilus>
Newsgroups comp.lang.python
Message-ID <mailman.9.1432459244.5151.python-list@python.org> (permalink)

Show all headers | View raw


On 22May2015 21:12, Lele Gaifax <lele@metapensiero.it> wrote:
>Chris Angelico <rosuav@gmail.com> writes:
>> On Sat, May 23, 2015 at 3:24 AM, Lele Gaifax <lele@metapensiero.it> wrote:
>>> Laura Creighton <lac@openend.se> writes:
>>>> In my corner of the world, everybody uses SQL.
>>>> [...]
>>>> The people who have tried SQLAlchemy really didn't like it, and of course
>>>> the people who haven't tried it do what their friends do, as usual.
>>>
>>> If these sentences are related, you must live in a very strange corner!
>>> ;-)
>
>> Not sure why. I'm in the same corner, I think - I use SQL, and not
>> SQLAlchemy if I can help it. I'd much rather just use psycopg2 and do
>> my own queries.
>
>Didn't mean to be so serious, but anyway...
>
>> SQLAlchemy has its uses, and it does solve a number of
>> issues in reasonably clean ways, but I don't like a few of its facets,
>> including its peculiar way of doing foreign key relationships. (You
>> put a foreign key in the child, and you put a relationship in the
>> parent, which feels backwards.)
>
>You are conflating two different layers, core and ORM. ORM relationships can
>be declared either on the parent or on the child, it's up to your taste.

Indeed.

I'm a big fan of SQLAlchemy myself. But I do not use the ORM stuff.

I like SQLAlchemy because:

  - it quotes for me, avoiding an infinity of pain and injection risk

  - it presents results as nice objects with attributes named after columns

  - it lets me write SQL queries as nice parameterised Python syntax instead of clunky SQL

  - it automatically hooks into various backends, which means I can write many 
  tests or prototypes using, for example, in-memory SQLite dummy databases 
  while still speaking to MySQL or PostgreSQL in the real world. (Obviously you 
  need to run some tests against the real thing, but looking for SQL logic 
  errors is readily tested against throwaway SQLite or the like.)

I stay away from the ORM; I'm effectively writing SQL directly but using better 
syntax. I'm not saying the ORM is bad - you can clearly do all sorts of great 
things with it, but I have not found it useful to me, and that may reflect my 
ORM design skills and/or lack of experience with it.

Cheers,
Cameron Simpson <cs@zip.com.au>

Ride to not crash. Dress to crash. Live to ride to not crash again.
        - Lawrence Smith, DoD#i, lawrence@msc.cornell.edu

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


Thread

Re: Camelot a good tool for me Cameron Simpson <cs@zip.com.au> - 2015-05-23 08:42 +1000

csiph-web