3 ms·
Postgres + SQLAlchemy + Flask + Flask-Restless -> one-page CRUD Restful API
by randomsearch 11y ago
Postgres + SQLAlchemy + Flask + Flask-Restless -> one-page CRUD Restful API
- rch 11y agoI've had a better experience with Flask-RESTful, even though it also obviously needs a lot more work. Did you happen to compare the two?
- aidos 11y agoI'd be interested in hearing other peoples' experiences too. I've tried both flask-restless and flask-restful previously but didn't get along with either of them. I recently created a new API and went for a very simple flask.Methodview along with Marshmallow [0] for (de)serialization. I then wrote a simple replacement for marshmallow-alchemy since it wouldn't do object loading without a lot of flapping about. I found Marshmallow really nice to work with (I'd been using Schematics in the past). [0] https://github.com/marshmallow-code/marshmallow https://github.com/marshmallow-code/marshmallow
- rch 11y agoI've taken to using an intermediate 'service' layer (in the parlance, but not structure, of overholt) to manage metadata on fields and inform serialization. It looks a bit like Marshmallow, but baked in as a Flask extension. I've been kicking around different approaches to this for over a decade, going back to Castor (Java data binding), and with Python, SQLAlchemy, and the libraries mentioned here I'm finally feeling optimistic. Request parsing in Flask-RESTful seems bolted on, and the fields in WTForms seem frustratingly redundant given that almost everything I do is going through the API anyway. Maybe focusing more on the Fields themselves will help tie it all together.
- hurtmyknee 11y agoFlask-RESTful worked out for me, I like how easy it is to define routes. I'm eager to try Falcon next: http://falconframework.org/ http://falconframework.org/
- mkane 11y agoI tried both flask-restless and restful as well, but like you have moved away from them to a simpler setup. Just using a simple flask app + blueprints with a few extra error handling / cors bits and a custom response class for json. I'm very happy with marshmallow too.
- randomsearch 11y agoI haven't done too much with either, but for a minimal example, Flask-Restless is more straightforward. Power vs configurability trade-off by the looks of it. I'll certainly keep Flask-RESTful in mind if things get more difficult in the future.
- mpdehaan2 11y agoAlso worth mentioning, a port of the Django REST Framework browser to Flask - http://www.flaskapi.org/ http://www.flaskapi.org/ - which doesn't do as much as DJRF, but it's nice to have the same browser, which is great. I actually like Django's querysets a little better than SQLAlchemy's, but most other things better in Flask. I may be a heretic. The declarative API in SQLAlchemy requires much more work to set up relations, and the Django way of being able to chain relations in a query with "__" is pretty friendly in ways that I like.
- deleted 11y ago[deleted]
- vfrogger 11y agoI recently ran across Falcon and I'm super excited to give it a go for my next API. http://falconframework.org/ http://falconframework.org/