Live data from Hacker News

SQLAlchemy 0.9.0 Released

sqlalchemy.org

31–40 of 43 posts

Re: SQLAlchemy 0.9.0 Released

#31

Thanks for this release. Learning SQL before ever touching an ORM, SQLAlchemy's approach makes a lot more sense to me than something "simplier" like Django's ORM. Anyone know, is there any chance Django would pull in SQLAlchemy core as a dependency and implement their ORM on top of it?

that idea has come up on many occasions and was seriously discussed some years ago. I don't think it's ever happening in that specific form; mostly because it would require that the Django ORM's behavior and usage contract not change at all in order to support backwards compatibility. This would be a very large task, at the very least for Django and probably for us as we make adjustments to support them. The feel and behavior of Django's ORM would invariably change quite palpably - even if you can get every function input and output to match, you still have what it looks like when you get a stack trace, an error message, etc. Django users would see lots of unfamiliar "sqlalchemy" lines in these stack traces and tracking down issues would then involve both Django and SQLAlchemy devs. Performance would also be a concern - keeping behavior exactly as is within Django might require some odd workarounds or additional logic which could prove to be complex and/or less performant.

That said, I have on occasion floated an alternative idea, which is to basically port the Django configurational and query system to SQLAlchemy entirely, doing away with full backwards compatibility and essentially providing a "transitional" platform, where you take an existing Django application and basically run it on top of a new ORM layer that actually uses the SQLAlchemy Session and unit of work model, but the majority of the Django configuration and queryset behavior remains available, thus making porting a relatively painless process (but still, there'd be a porting process). This approach has two advantages. One is, it's actually doable, we're providing a new platform and not trying to duplicate an existing one. The other is, we're actually delivering to a Django application some of the biggest advantages SQLAlchemy has, which are namely the ORM features like unit of work/identity map, the instrumentation model including collections and eager loading support, and inheritance support.

Nobody has time / motivation for that idea either, but I think if it ever happened, it would be more pragmatic.

Re: SQLAlchemy 0.9.0 Released

#32
post #8

> support for Postgresql JSON types, This. Finally :) I know I was searching this a few months ago and there was a long due ticket for this to be added. Thank you whoever did this patch. A side note. I personally use Pyramid (I use Pyramid more, however) and Flask. For Flask project I never use flask-sqlalchemy because mitsuhiko doesn't seem to update the repository as often as he should. A lot of outstanding tickets…

In this combination SQLAlchemy feels a bit mismatched because it is heavier than Flask itself, somewhat negating the joy of using a micro framework. On small projects I enjoyed using things like the web2py Data Access Layer, a single module sweetening access to a large number of databases.

https://code.google.com/p/web2py/source/browse/gluon/dal.py

Re: SQLAlchemy 0.9.0 Released

#33
post #12
post #8

> support for Postgresql JSON types, This. Finally :) I know I was searching this a few months ago and there was a long due ticket for this to be added. Thank you whoever did this patch. A side note. I personally use Pyramid (I use Pyramid more, however) and Flask. For Flask project I never use flask-sqlalchemy because mitsuhiko doesn't seem to update the repository as often as he should. A lot of outstanding tickets…

Currently on a big project using flask + sqlalchemy and didn't want to use flask-sqlalchemy as well. At first, it was because it didn't seem like i needed to, then it was for a better understanding of the sqlalchemy session / flask request lifecycle coordination. That knowledge proved to be very useful once i needed to reuse my stack in a celery task.

To solve this, I have a custom Celery instance that wraps each task in my flask app's context. So you can treat celery tasks as just another request.

Re: SQLAlchemy 0.9.0 Released

#34
post #24

Earlier quoted context omitted.

The ORM is mediocre compared to SQLAlchemy, the template system is weak compared to Jinja2. If you swap Django's ORM with SQLAlchemy and replace Django Templates with Jinja2, you end up with something like Flask. The killer feature for me is Django's "admin" app. When I'm not using the "admin", the rest of Django kind of gets in the way. Nowadays I prefer a less opinionated framework like Flask if I'm not using the "…

In my experience the true killer feature of Django is the "batteries included" approach. If you stay within the boundaries of the framework you get a standard project structure, a decent ORM, a template language (dogmatically crippled, but that's a different discussion), a forms handling library, and the typical assorted framework toolkit (internationalization, logging, development server, utilities, etc) -- all equa…

Nah, I'm not sure having all the libs bound together is the killer. I think it's having all those libs with a cohesive set of docks and with a "single" voice. I'm not sure that packaging Flask, Jinja2/Babel, WTForms, SQLAlchemy, and Werkzeug (dev / debug server) together -- that should cover the non-admin Django -- would improve the usage. Technically, Jinja2 and Werkzeug are already dependencies of Flask, and their extensions page [0] are fairly instructive on what other libs to pull in for the other needs. There's also no reason one can't use Django, Jinja2/Babel, WTF, SQLA, and Werkzeug... we do!

[0] http://flask.pocoo.org/extensions/

Re: SQLAlchemy 0.9.0 Released

#35
post #12

Earlier quoted context omitted.

Currently on a big project using flask + sqlalchemy and didn't want to use flask-sqlalchemy as well. At first, it was because it didn't seem like i needed to, then it was for a better understanding of the sqlalchemy session / flask request lifecycle coordination. That knowledge proved to be very useful once i needed to reuse my stack in a celery task.

To solve this, I have a custom Celery instance that wraps each task in my flask app's context. So you can treat celery tasks as just another request.

Yeap, that's what i did as well, and i think that's the documented way ( using a flask test request context i think). But having to do this let me understand a lot more about sqlalchemy session, flushing and object states, in a multithreaded environment. I recommend doing that for an in-depth understanding.

Re: SQLAlchemy 0.9.0 Released

#36
post #20

I'd love to have something as good as sqlalchemy in go

I looked at Go a little bit as maybe a place to write a kind of "uber-Core" system, e.g. a high performance database abstraction layer that could power libs in other languages. But apparently Go is not at all designed to be embedded in other runtimes, it isn't even possible. Also it seems to lack a standard database API and the connectors that were there seemed a little all over the place.

Did you check out rust? That's within rust's feature set, though it isn't "production ready" yet.

Re: SQLAlchemy 0.9.0 Released

#37

Thanks for this release. Learning SQL before ever touching an ORM, SQLAlchemy's approach makes a lot more sense to me than something "simplier" like Django's ORM. Anyone know, is there any chance Django would pull in SQLAlchemy core as a dependency and implement their ORM on top of it?

The ORM is mediocre compared to SQLAlchemy, the template system is weak compared to Jinja2. If you swap Django's ORM with SQLAlchemy and replace Django Templates with Jinja2, you end up with something like Flask. The killer feature for me is Django's "admin" app. When I'm not using the "admin", the rest of Django kind of gets in the way. Nowadays I prefer a less opinionated framework like Flask if I'm not using the "…

Django 1.7 will support composite keys (it's been worked on for several years.)

https://code.djangoproject.com/wiki/Version1.7Roadmap

Re: SQLAlchemy 0.9.0 Released

#38
post #8

> support for Postgresql JSON types, This. Finally :) I know I was searching this a few months ago and there was a long due ticket for this to be added. Thank you whoever did this patch. A side note. I personally use Pyramid (I use Pyramid more, however) and Flask. For Flask project I never use flask-sqlalchemy because mitsuhiko doesn't seem to update the repository as often as he should. A lot of outstanding tickets…

I also don't use flask-sqlalchemy because it's too infrequently maintained, and I also don't like that it deviates from pure SqlAlchemy style in (eg) model decarations - I really don't see the need for that.

Re: SQLAlchemy 0.9.0 Released

#39
post #32
post #8

> support for Postgresql JSON types, This. Finally :) I know I was searching this a few months ago and there was a long due ticket for this to be added. Thank you whoever did this patch. A side note. I personally use Pyramid (I use Pyramid more, however) and Flask. For Flask project I never use flask-sqlalchemy because mitsuhiko doesn't seem to update the repository as often as he should. A lot of outstanding tickets…

In this combination SQLAlchemy feels a bit mismatched because it is heavier than Flask itself, somewhat negating the joy of using a micro framework. On small projects I enjoyed using things like the web2py Data Access Layer, a single module sweetening access to a large number of databases. https://code.google.com/p/web2py/source/browse/gluon/dal.py

I don't find any mismatch in using a heavy framework like SqlAlchemy with Flask - I choose Flask because I want my web framework to be lightweight, but I use SqlAlchemy because I want the full power of that library. I think it's fine to take a component-level view and choose light- or heavy-weight components as you see fit.

Re: SQLAlchemy 0.9.0 Released

#40
I dunno. I just don't get ORMs. I certainly see their use case in easy prototyping, but with the advent of NoSQL, why not just prototype with MongoDB, or similar, and if it turns out your data is close to uniform in structure, just switch over to MySQL, or similar.

To keep my code portable, I stick to standard SQL and don't use any stored procedures. I'm sure this is probably not a tenable strategy for web-scale apps, but with 100s/1000s of users and only millions of records, it seems to work just fine.

This comment is no way meant to disparage SQLAlchemy which by all accounts seems to be a first rate work of engineering. I am speaking of ORMs in general, and why should we use them.

Post reply on HN