{ "info": { "author": "Rohan Mathur", "author_email": "rohan@rmathur.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Build Tools" ], "description": "modelstruct\n=========\nA simple Python module to expose SQLAlchemy model structures as a RESTful API.\n\n## Example\nPython model:\n\n```python\nclass Book(db.Model):\n __tablename__ = 'books'\n\n id = db.Column(db.Integer, primary_key=True)\n time_created = db.Column(db.DateTime)\n name = db.Column(db.String(140), unique=True)\n description = db.Column(db.String(320))\n in_inventory = db.Column(db.Boolean, default=True)\n user_id = db.Column(db.Integer)\n author = db.Column(db.String(140))\n\n def __init__(self, name, author, description, in_inventory, user_id):\n self.name = name\n self.description = description\n self.in_inventory = in_inventory\n self.user_id = user_id\n self.time_created = datetime.datetime.now()\n self.author = author\n\n def __repr__(self):\n return '' % self.id\n```\n\nJSON exposed via a RESTful API for this model:\n\n```json\n{\n \"structure\": {\n \"author\": \"VARCHAR(140)\",\n \"description\": \"VARCHAR(320)\",\n \"id\": \"INTEGER\",\n \"in_inventory\": \"BOOLEAN\",\n \"name\": \"VARCHAR(140)\",\n \"time_created\": \"DATETIME\",\n \"user_id\": \"INTEGER\"\n }\n}\n```\n\n## Install\n\n```\npip install modelstruct\n```\n\n## Usage\n\n1. Import the Python module\n```python\nfrom modelstruct import get_json\n```\n\n2. Create a new route for the endpoint you want to be your API (below the example is in Flask, and creates the API at the location `/models`, with the model class name `MODEL_NAME_HERE`)\n\n```python\n@app.route('/models', methods=['GET'])\ndef get_model_structure():\n return get_json(MODEL_NAME_HERE)\n```\n\n3. That's it! Send a GET request to the endpoint and get the model's structure.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mathur/modelstruct", "keywords": "sqlalchemy models structure expose api", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "modelstruct", "package_url": "https://pypi.org/project/modelstruct/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/modelstruct/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mathur/modelstruct" }, "release_url": "https://pypi.org/project/modelstruct/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "A module to expose the structure of SQLAlchemy models as a RESTful API", "version": "1.0.0" }, "last_serial": 1898304, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "a9fa272086b434c25f09e04b8cafcc4b", "sha256": "9e3a5d25bd90455c065ed008013727ea3712fe31b2b838e1f7777b567bcad5f1" }, "downloads": -1, "filename": "modelstruct-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a9fa272086b434c25f09e04b8cafcc4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3066, "upload_time": "2016-01-11T00:03:51", "url": "https://files.pythonhosted.org/packages/30/5c/6a42e838b15b892dddf36b5a4498994743f935dab8495edb48f0a5fd1682/modelstruct-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a9fa272086b434c25f09e04b8cafcc4b", "sha256": "9e3a5d25bd90455c065ed008013727ea3712fe31b2b838e1f7777b567bcad5f1" }, "downloads": -1, "filename": "modelstruct-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a9fa272086b434c25f09e04b8cafcc4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3066, "upload_time": "2016-01-11T00:03:51", "url": "https://files.pythonhosted.org/packages/30/5c/6a42e838b15b892dddf36b5a4498994743f935dab8495edb48f0a5fd1682/modelstruct-1.0.0.tar.gz" } ] }