sqlalchemy-jsonapi
sqlalchemy-jsonapi copied to clipboard
Docs incomplete
Sadly, the docs are somewhat incomplete.
Can you provide a fully working, complete example.py (like https://github.com/ColtonProvias/flask-jsonapi/blob/master/example.py, or the classical ToDo example) for Flask?
I'm happy to help write some, but I'm stuck at how it is meant to work - I could fiddle something together but I'd prefer to know your intention on how it is to be used.
Thanks!
Yeah, being new to Python, I'm lost as well without a complete example. I might be able to figure it out if I could get past the first error which comes from following the very short doc:
api = FlaskJSONAPI(app, db)
TypeError: 'NoneType' object is not callable
To those who use Flask, setting up SQLAlchemy-JSONAPI can be extremely complex and frustrating.
So true and very cruel to bait us like this. Moving back to marshmallow_jsonapi. Ugh.
Hey there. Any complete examples? I am getting the same error as @juanitogan using the following requirements:
enum34==1.1.2
Flask==0.10.1
Flask-SQLAlchemy==2.1
inflection==0.3.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
psycopg2==2.6.1
SQLAlchemy==1.0.12
SQLAlchemy-JSONAPI==4.0.4
Werkzeug==0.11.4
Thanks!
Looks like blinker
needs to be added to the package dependencies.
>>> import sqlalchemy_jsonapi.flaskext
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python2.7/site-packages/sqlalchemy_jsonapi/flaskext.py", line 13, in <module>
from blinker import signal
ImportError: No module named blinker
pip install blinker
gets past the initial error.
Something like this worked for me:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy_jsonapi import FlaskJSONAPI
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///my_existing_db.db'
db = SQLAlchemy(app)
class Person(db.Model):
__tablename__ = 'person'
id = db.Column(db.Integer, primary_key=True)
age = db.Column(db.Integer, nullable=False)
api = FlaskJSONAPI(app, db)
if __name__ == "__main__":
app.run()
I'll get an example into the docs soon! Got a little preoccupied with a project that this library is being used in.
@ColtonProvias - Happy to help as well with any documentation, testing, what have you. This is a fantastic idea overall, especially for Ember developers. If only I could get it correctly configured...
Ember developer here as well, Datamance. We're using it on https://mynewleaf.co for most of our APIs. Of course it had to be bastardized a little bit to meet some requirements, but improvements will be flowing back into this project shortly. Pull requests and such are always appreciated!
@jesselang Blinker has been added. I'll update on PyPI soon.
@berlincount There is an example at sqlalchemy_jsonapi/tests/app.py. I'm still going to flesh out the docs some.