{ "info": { "author": "Siddhant Goel", "author_email": "me@sgoel.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Flask", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "Flask-FileAlchemy\n=================\n\n.. image:: https://badge.fury.io/py/flask-filealchemy.svg\n :target: https://pypi.python.org/pypi/flask-filealchemy\n\n.. image:: https://travis-ci.org/siddhantgoel/flask-filealchemy.svg?branch=stable\n :target: https://travis-ci.org/siddhantgoel/flask-filealchemy\n\n:code:`Flask-FileAlchemy` lets you use YAML-formatted plain-text files as the\ndata store for your Flask_ app.\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install flask-filealchemy\n\nBackground\n----------\n\nWhile there are better data stores to use in production than plain-text, the\nconstraints on data stores for applications that only have to run locally are\nmuch more relaxed. For such applications, it's normally OK to sacrifice on\nperformance for ease of use.\n\nOne very strong use case here is generating static sites. While you can use\n`Frozen-Flask`_ to \"freeze\" an entire Flask application to a set of HTML files,\nyour application still needs to read data from somewhere. This means you'll need\nto set up a data store, which (locally) tends to be file based SQLite. While\nthat does the job extremely well, this also means executing SQL statements to\ninput data.\n\nDepending on how many data models you have and what types they contain, this\ncan quickly get out of hand (imagine having to write an :code:`INSERT` statement\nfor a blog post).\n\nIn addition, you can't version control your data. Well, technically you can,\nbut the diffs won't make any sense to a human.\n\nFlask-FileAlchemy lets you use an alternative data store - plain text files.\n\nPlain text files have the advantage of being much easier to handle for a human.\nPlus, you can version control them so your application data and code are both\nchecked in together and share history.\n\nFlask-FileAlchemy lets you enter your data in YAML formatted plain text files\nand loads them according to the SQLAlchemy_ models you've defined using\n`Flask-SQLAlchemy`_ This data is then put into whatever data store you're using\n(in-memory SQLite works best) and is then ready for your app to query however it\npleases.\n\nThis lets you retain the comfort of dynamic sites without compromising on the\nsimplicity of static sites.\n\nUsage\n-----\n\nDefine your data models using the standard (Flask-)SQLAlchemy API.\n\n.. code-block:: python\n\n app = Flask(__name__)\n\n # configure Flask-SQLAlchemy\n app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'\n\n db = SQLAlchemy(app)\n\n class BlogPost(db.Model):\n __tablename__ = 'blog_posts'\n\n slug = Column(String(255), primary_key=True)\n title = Column(String(255), nullable=False)\n contents = Column(Text, nullable=False)\n\nThen, create a :code:`data/` directory somewhere on your disk (to keep things\nsimple, it's recommended to have this directory in the application root). For\neach model you've defined, create a directory under this :code:`data/` directory\nwith the same name as the :code:`__tablename__` attribute.\n\nIn this example, we'll add the following contents to\n:code:`data/blog_posts/first-post-ever.yml`.\n\n.. code-block:: yaml\n\n slug: first-post-ever\n title: First post ever!\n contents: |\n This blog post talks about how it's the first post ever!\n\nFor \"smaller\" models which don't have more than 2-3 fields, Flask-FileAlchemy\nsupports reading from an :code:`_all.yml` file. In such a case, instead of\nadding one file for every row, simply add all the rows in the :code:`_all.yml`\nfile inside the table directory.\n\nIn this example, this could look like the following.\n\n.. code-block:: yaml\n\n - slug: first-post-ever\n title: First post ever!\n contents: This blog post talks about how it's the first post ever!\n - slug: second-post-ever\n title: second post ever!\n contents: This blog post talks about how it's the second post ever!\n\nFinally, configure :code:`Flask-FileAlchemy` with your setup and ask it to load\nall your data.\n\n.. code-block:: python\n\n # configure Flask-FileAlchemy\n app.config['FILEALCHEMY_DATA_DIR'] = os.path.join(\n os.path.dirname(os.path.realpath(__file__)), 'data'\n )\n app.config['FILEALCHEMY_MODELS'] = (BlogPost,)\n\n # load tables\n FileAlchemy(app, db).load_tables()\n\n:code:`Flask-FileAlchemy` then reads your data from the given directory, and\nstores them in the data store of your choice that you configured\n:code:`Flask-FileAlchemy` with (the preference being\n:code:`sqlite:///:memory:`).\n\nPlease note that it's not possible to write to this database using\n:code:`db.session`. Well, technically it's allowed, but the changes your app\nmakes will only be reflected in the in-memory data store but won't be persisted\nto disk.\n\nContributing\n------------\n\nContributions are most welcome!\n\nPlease make sure you have Python 3.4+ and pipenv_ installed.\n\n1. Git clone the repository -\n :code:`git clone https://github.com/siddhantgoel/flask-filealchemy`.\n\n2. Install the packages required for development -\n :code:`pipenv install --dev`\n\n3. That's basically it. You should now be able to run the test suite -\n :code:`py.test`.\n\n.. _Flask: http://flask.pocoo.org\n.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/\n.. _Frozen-Flask: https://pythonhosted.org/Frozen-Flask/\n.. _SQLAlchemy: https://www.sqlalchemy.org/\n.. _pipenv: https://pipenv.readthedocs.io/en/latest/\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/siddhantgoel/flask-filealchemy", "keywords": "flask,sqlalchemy,yaml,plaintext,web", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "flask-filealchemy", "package_url": "https://pypi.org/project/flask-filealchemy/", "platform": "", "project_url": "https://pypi.org/project/flask-filealchemy/", "project_urls": { "Homepage": "https://github.com/siddhantgoel/flask-filealchemy" }, "release_url": "https://pypi.org/project/flask-filealchemy/0.3.0/", "requires_dist": [ "Flask-SQLAlchemy (>=2.1)", "ruamel.yaml (>=0.15)" ], "requires_python": ">=3.4.0", "summary": "YAML-formatted plain-text file based models for Flask backed by Flask-SQLAlchemy", "version": "0.3.0" }, "last_serial": 4492700, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e260ee25aba1a1674f34c3f037d9c187", "sha256": "e7208f13b22bc8fa10c2dc2abf9a4663c7c39704ae3a9ce8229cbb7416d956a7" }, "downloads": -1, "filename": "flask_filealchemy-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e260ee25aba1a1674f34c3f037d9c187", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.0", "size": 5101, "upload_time": "2018-10-13T12:21:51", "url": "https://files.pythonhosted.org/packages/df/4a/0efbf636d35974c93dacea03522a6070020a03f6fdbd9739a9fad32bf3ba/flask_filealchemy-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01259fe4f96031c5b75a921ec3f145e2", "sha256": "7a5d3862020729ae106772d9dfc77e123caa575b53f86f89f8079c34107a10ba" }, "downloads": -1, "filename": "flask-filealchemy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "01259fe4f96031c5b75a921ec3f145e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.0", "size": 5504, "upload_time": "2018-10-13T12:21:52", "url": "https://files.pythonhosted.org/packages/19/be/11982a77211a14e258a834dc154ca83a6500a478f7f55799334d7d41279a/flask-filealchemy-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6b0b24056a918fb57d7c06670ead3100", "sha256": "1dee909522880acaa3ed2bc7ea363e0c5a24a7b692aa5c60aeeb5a2a5b067ed8" }, "downloads": -1, "filename": "flask_filealchemy-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6b0b24056a918fb57d7c06670ead3100", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.0", "size": 5315, "upload_time": "2018-10-18T16:31:49", "url": "https://files.pythonhosted.org/packages/df/1d/266d49724b822d34be619fdc5a9afd78868c3652be72d00a8af21adc1c08/flask_filealchemy-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a62937d3f489d1d19e373645601f907d", "sha256": "d29f745844ed41c3a0a4c53c3b237707a915019f5bf88cfb4e199fd8cd8a7086" }, "downloads": -1, "filename": "flask-filealchemy-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a62937d3f489d1d19e373645601f907d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.0", "size": 5718, "upload_time": "2018-10-18T16:31:51", "url": "https://files.pythonhosted.org/packages/07/c0/1d96a24b1ee09bb0600abf24a406d7bd60d82beaa23f9ea07cbd522cb857/flask-filealchemy-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "e51df4cb05383f34d997a419ccc5017c", "sha256": "ca2ae6afdf80d26271c5d69b38927afe7553e4cffb1e6a3c5882b247bee2858d" }, "downloads": -1, "filename": "flask_filealchemy-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e51df4cb05383f34d997a419ccc5017c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4.0", "size": 5605, "upload_time": "2018-11-16T07:42:54", "url": "https://files.pythonhosted.org/packages/2b/84/40e1d1f52aac97a9dca215633783956e62f5cffe34579b108fab4e5911fd/flask_filealchemy-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9698c7dd7c9e57835fff17316ef53a50", "sha256": "188bae1a8a252958772efc1cb87c6143e44d60e68c1a90354a7c1ea684b43c3f" }, "downloads": -1, "filename": "flask-filealchemy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "9698c7dd7c9e57835fff17316ef53a50", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4.0", "size": 6074, "upload_time": "2018-11-16T07:42:55", "url": "https://files.pythonhosted.org/packages/f1/f7/2ab0402f45dbbc2ebb50cedb91b8be282ef782a5ff7b11905d238d755030/flask-filealchemy-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e51df4cb05383f34d997a419ccc5017c", "sha256": "ca2ae6afdf80d26271c5d69b38927afe7553e4cffb1e6a3c5882b247bee2858d" }, "downloads": -1, "filename": "flask_filealchemy-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e51df4cb05383f34d997a419ccc5017c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4.0", "size": 5605, "upload_time": "2018-11-16T07:42:54", "url": "https://files.pythonhosted.org/packages/2b/84/40e1d1f52aac97a9dca215633783956e62f5cffe34579b108fab4e5911fd/flask_filealchemy-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9698c7dd7c9e57835fff17316ef53a50", "sha256": "188bae1a8a252958772efc1cb87c6143e44d60e68c1a90354a7c1ea684b43c3f" }, "downloads": -1, "filename": "flask-filealchemy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "9698c7dd7c9e57835fff17316ef53a50", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4.0", "size": 6074, "upload_time": "2018-11-16T07:42:55", "url": "https://files.pythonhosted.org/packages/f1/f7/2ab0402f45dbbc2ebb50cedb91b8be282ef782a5ff7b11905d238d755030/flask-filealchemy-0.3.0.tar.gz" } ] }