Camelot a good tool for me

Cameron Simpson cs at zip.com.au
Fri May 22 18:42:29 EDT 2015


On 22May2015 21:12, Lele Gaifax <lele at metapensiero.it> wrote:
>Chris Angelico <rosuav at gmail.com> writes:
>> On Sat, May 23, 2015 at 3:24 AM, Lele Gaifax <lele at metapensiero.it> wrote:
>>> Laura Creighton <lac at 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 at zip.com.au>

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



More information about the Python-list mailing list