Live data from Hacker News

SQLAlchemy 2.0 Released

sqlalchemy.org

21–30 of 84 posts

Re: SQLAlchemy 2.0 Released

#21
post #6

Sorry for detracting from the release news but SQLAlchemy has to have the least helpful website of any major library I can think of. I'm trying to find basic 101 code examples and it's just one wall of text after another. I found how to cite SQLAlchemy in a research paper and have yet to find a single code example.

When I see such a poor website, I also expect the codebase to be clunky and cluttered. Better alternative: - https://pugsql.org/

This is neat - I'd never heard of it.

I've been using psycopg2 directly with a thin layer for managing connections and transactions using thread-locals for a long time - RealDictRow and some adapters for jsonb and a few other types make it really easy to work with.

Re: SQLAlchemy 2.0 Released

#22

Earlier quoted context omitted.

Out of curiosity, what's the benefit of async for you?

Async sqlalchemy is required if we want to use an async appserver(tornado). We can serve a lot more requests per second with async. Otherwise, tornado was sync and could only serve one request synchronously at one time.

Thanks:)

Re: SQLAlchemy 2.0 Released

#23
post #6

Sorry for detracting from the release news but SQLAlchemy has to have the least helpful website of any major library I can think of. I'm trying to find basic 101 code examples and it's just one wall of text after another. I found how to cite SQLAlchemy in a research paper and have yet to find a single code example.

When I see such a poor website, I also expect the codebase to be clunky and cluttered. Better alternative: - https://pugsql.org/

I've worked for close to a decade with Django's ORM and recently with TypeORM, both have been simple to use and generally (minus some weird things I tried to do) a pleasure. I recently started working with a not so important project at my current job with sqlalchemy because I had to use Flask, I cannot describe the pain I've felt working with this, I dread having to write yet another query with sqlalchemy. The docs are terrible, some of the worst I've ever seen, an obscure and undocumented government library I'm also using at work has been easier to learn by reading its code than sqlalchemy. Someone above mentioned that the new 2.0 docs are better, I seriously hope they are, they will make my suffering more tolerable. However, even if the docs are good the API is still the worst and least intuitive I've ever seen, it honestly feels like I'm writing raw sql code shaped like python code. But it is weird, non standard and difficult to follow, unlike the official python sql interface. I recently had to write an upset and it felt like I was trying to summon a forgotten demon. It would have honestly been much easier to just write it in raw sql.

I'm sorry for the wall of text, I wanted to let you know that I'm very grateful for you suggesting that library. I hope I can migrate this (still) relatively small codebase away from sqlalchemy. I'm going to give pugsql and peewee a try, both have been mentioned in this thread as good alternatives.

I can summarize my basic complain here: the abstraction layer that sqlalchemy provides is more complex than SQL itself. It's almost not worth it, add to that the docs are a huge mess and you get something only diehards and people who have been using it for decades want to use.

Re: SQLAlchemy 2.0 Released

#24
It’s honestly something of a marvel to see a big ol’ framework like SQLAlchemy successfully manage these big structural api changes. The changes that have lead up to v1.4 and v2.0 have been very significant improvements to the user interface, and have kept the library up to date with the language in a way that is rare to see for a code base of such complexity. Also the new unified bulk insert interface is a big win for my ETL workflows.

Hats of to everyone be involved!

Re: SQLAlchemy 2.0 Released

#25
post #2

Does it fully support types? Edit: Oh, it seems to, that's big. For comparison, Hibernate, the Java mammoth ORM, as far as I know, never fully moved to Java 5 generics (released 18 years ago). Also dataclasses and enums. Also big, since there used to be a lot of duplication in configuration, SQLAlchemy doing its thing and the rest of the codebase just using now standard Python 3 features. Cool!

Not only are the ORM objects typed, the query results are typed too. Last time I checked on 2.0 progress there wasn't a feasible way to implement this, so I'm thrilled to see that it made the release.

    # (variable) stmt: Select[Tuple[int, str]]
    stmt = select(User.id, User.name)
    
    with Session(e) as sess:
        for row in sess.execute(stmt):
            # (variable) row: Row[Tuple[int, str]]
            print(row)
    
        # (variable) users: Sequence[User]
        users = sess.scalars(select(User)).all()
    
        # (variable) users_legacy: List[User]
        users_legacy = sess.query(User).all()
https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html...

Re: SQLAlchemy 2.0 Released

#26
post #19

I would urge people who have had issues with the documentation to give the 2.0 documentation a try. Many aspects of it have been completely rewritten, both to correctly describe things in terms of the new APIs as well as to modernize a lot of old documentation that was written many years ago. First off, SQLAlchemy's docs are pretty easy to get to, for a direct link just go to: https://docs.sqlalchemy.org/ It's an eso…

Great tool. I think this is why folks have trouble finding the docs:

Whole entire site is docs everywhere, including home page. Links to "docs" are tiny on the home page. Main menu calls them "library" instead of docs, why?

Majority of the stuff is focused on migration rather than new users. These two should be separated into separate tracks immediately. There is an attempt, but it gets lost somehow.

Also the release page linked here and "what's new in 2.0" go straight into the deep end, "inside baseball" style. These kind of pages should be very light. Tons of history-I'm personally not interested when trying to get something done. Unsolicited advice, move that into another blog post. ;-)

Re: SQLAlchemy 2.0 Released

#27
post #10
post #6

Sorry for detracting from the release news but SQLAlchemy has to have the least helpful website of any major library I can think of. I'm trying to find basic 101 code examples and it's just one wall of text after another. I found how to cite SQLAlchemy in a research paper and have yet to find a single code example.

Check out pugsql, we switched from SQLAlchemy to that because the former was overkill, and way too complex.

I find ORM models useful for type checking and migrations, what is your experience for this with pugsql?

Re: SQLAlchemy 2.0 Released

#28
post #19

I would urge people who have had issues with the documentation to give the 2.0 documentation a try. Many aspects of it have been completely rewritten, both to correctly describe things in terms of the new APIs as well as to modernize a lot of old documentation that was written many years ago. First off, SQLAlchemy's docs are pretty easy to get to, for a direct link just go to: https://docs.sqlalchemy.org/ It's an eso…

Great tool. I think this is why folks have trouble finding the docs: Whole entire site is docs everywhere, including home page. Links to "docs" are tiny on the home page. Main menu calls them "library" instead of docs, why? Majority of the stuff is focused on migration rather than new users. These two should be separated into separate tracks immediately. There is an attempt, but it gets lost somehow. Also the release…

The link I posted here is the blog post. That's why it's historical and chatty, it's the blog post.

Re: SQLAlchemy 2.0 Released

#29
post #28

Earlier quoted context omitted.

Great tool. I think this is why folks have trouble finding the docs: Whole entire site is docs everywhere, including home page. Links to "docs" are tiny on the home page. Main menu calls them "library" instead of docs, why? Majority of the stuff is focused on migration rather than new users. These two should be separated into separate tracks immediately. There is an attempt, but it gets lost somehow. Also the release…

The link I posted here is the blog post. That's why it's historical and chatty, it's the blog post.

Love your tools!

I think you should consider changing "library" to "documentation" - for whatever reason I also struggled to discover "library" actually meant docs - but only after I also clicked on a specific version.

I think the best UI/UX for this is something like django's [0], where "documentation" brings you straight to the latest version's documentation.

[0] https://www.djangoproject.com/

Re: SQLAlchemy 2.0 Released

#30
SQLAlchemy's lightweight SQL wrapping was a revelation when I came across it, but I've come to rely a lot on Django's migration tooling, enough so to choose Django for projects. What do people using SQLAlchemy use for migrations?
Post reply on HN