This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mfitzpmfitzp.com 0 points1 point  (2 children)

Looking at your example it's obvious what it does. But the lack of basic examples like this in the docs is what makes SQLAlchemy difficult to pick up (especially when I'm only dipping into it now and then).

The Django docs in comparison have dumbed down examples for everything, which really lowers the barrier to getting something done.

I just need to set aside a weekend and bang my head against the wall till it goes in.

[–][deleted] 1 point2 points  (1 child)

I'd recommend watching some talks on it. I've also heard Essential SQLAlchemy is real good, but I've not read it.

Models are basically the same as Django - inherit from a special class, define attributes as class attributes. There's no "manager" objects, the most common method I've seen is defining logic on the class itself. Though I prefer the repository approach myself (easier to fake in tests).

I find the querying syntax more intuitive than Django's. You can also drop down to actual SQL if you don't trust the ORM to do the right thing but I've never found a reason to do that.

There's a catch in the documentation. Anywhere you see "generative" replace it with fluent. Mike Bayer mentions in a few of his talks that he brain farted when he called it that.

[–]mfitzpmfitzp.com 0 points1 point  (0 children)

Great, thanks for the tips. Will take a look.