├── .carthorse.yml ├── .circleci └── config.yml ├── .gitignore ├── .readthedocs.yml ├── LICENSE.rst ├── README.rst ├── __init__.py ├── docs ├── Makefile ├── api.rst ├── changes.rst ├── conf.py ├── development.rst ├── index.rst ├── license.rst └── use.rst ├── fastapi_sqlalchemy └── __init__.py ├── setup.py └── tests └── __init__.py /.carthorse.yml: -------------------------------------------------------------------------------- 1 | carthorse: 2 | version-from: setup.py 3 | when: 4 | - version-not-tagged 5 | actions: 6 | - run: "sudo pip install -e .[build]" 7 | - run: "sudo python setup.py sdist bdist_wheel" 8 | - run: "twine upload -u chrisw -p $PYPI_PASS dist/*" 9 | - create-tag 10 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | python: cjw296/python-ci@1.2 5 | 6 | common: &common 7 | jobs: 8 | 9 | - python/pip-run-tests: 10 | name: python36 11 | image: circleci/python:3.6 12 | 13 | - python/pip-run-tests: 14 | name: python37 15 | image: circleci/python:3.7 16 | 17 | - python/coverage: 18 | name: coverage 19 | requires: 20 | - python36 21 | - python37 22 | 23 | - python/release: 24 | name: release 25 | config: .carthorse.yml 26 | requires: 27 | - coverage 28 | filters: 29 | branches: 30 | only: master 31 | 32 | workflows: 33 | push: 34 | <<: *common 35 | periodic: 36 | <<: *common 37 | triggers: 38 | - schedule: 39 | cron: "0 0 * * *" 40 | filters: 41 | branches: 42 | only: master 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /*.egg-info 3 | /include 4 | /lib 5 | .coverage* 6 | _build/ 7 | /.cache 8 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | python: 3 | version: 3.7 4 | install: 5 | - method: pip 6 | path: . 7 | extra_requirements: 8 | - build 9 | -------------------------------------------------------------------------------- /LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, Chris Withers 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, 8 | and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 16 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | 2 | FastAPI tools for SQLAlchemy 3 | ============================ 4 | 5 | |CircleCI|_ |Docs|_ 6 | 7 | .. |CircleCI| image:: https://circleci.com/gh/cjw296/fastapi_sqlalchemy/tree/master.svg?style=shield 8 | .. _CircleCI: https://circleci.com/gh/cjw296/fastapi_sqlalchemy/tree/master 9 | 10 | .. |Docs| image:: https://readthedocs.org/projects/fastapi_sqlalchemy/badge/?version=latest 11 | .. _Docs: http://fastapi_sqlalchemy.readthedocs.org/en/latest/ 12 | 13 | Tools to allow FastAPI and SQLAlchemy to work better together, particularly when it comes to pydantic. 14 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjw296/fastapi_sqlalchemy/980ee1570b2a872bc4be136355c58ec399186d4c/__init__.py -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | 9 | # Internal variables. 10 | PAPEROPT_a4 = -D latex_paper_size=a4 11 | PAPEROPT_letter = -D latex_paper_size=letter 12 | ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 13 | 14 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest 15 | 16 | help: 17 | @echo "Please use \`make ' where is one of" 18 | @echo " html to make standalone HTML files" 19 | @echo " dirhtml to make HTML files named index.html in directories" 20 | @echo " pickle to make pickle files" 21 | @echo " json to make JSON files" 22 | @echo " htmlhelp to make HTML files and a HTML help project" 23 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 24 | @echo " changes to make an overview of all changed/added/deprecated items" 25 | @echo " linkcheck to check all external links for integrity" 26 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 27 | 28 | clean: 29 | -rm -rf _build/* 30 | 31 | html: 32 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html 33 | @echo 34 | @echo "Build finished. The HTML pages are in _build/html." 35 | 36 | dirhtml: 37 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml 38 | @echo 39 | @echo "Build finished. The HTML pages are in _build/dirhtml." 40 | 41 | pickle: 42 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle 43 | @echo 44 | @echo "Build finished; now you can process the pickle files." 45 | 46 | json: 47 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json 48 | @echo 49 | @echo "Build finished; now you can process the JSON files." 50 | 51 | htmlhelp: 52 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp 53 | @echo 54 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 55 | ".hhp project file in _build/htmlhelp." 56 | 57 | latex: 58 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex 59 | @echo 60 | @echo "Build finished; the LaTeX files are in _build/latex." 61 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 62 | "run these through (pdf)latex." 63 | 64 | changes: 65 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes 66 | @echo 67 | @echo "The overview file is in _build/changes." 68 | 69 | linkcheck: 70 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck 71 | @echo 72 | @echo "Link check complete; look for any errors in the above output " \ 73 | "or in _build/linkcheck/output.txt." 74 | 75 | doctest: 76 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest 77 | @echo "Testing of doctests in the sources finished, look at the " \ 78 | "results in _build/doctest/output.txt." 79 | -------------------------------------------------------------------------------- /docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | .. automodule:: fastapi_sqlalchemy 5 | :members: 6 | :member-order: bysource 7 | -------------------------------------------------------------------------------- /docs/changes.rst: -------------------------------------------------------------------------------- 1 | .. py:currentmodule:: fastapi_sqlalchemy 2 | 3 | Changes 4 | ======= 5 | 6 | X.Y.Z (DD MMM 2019) 7 | ------------------- 8 | 9 | - Initial release 10 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import datetime, os, pkg_resources 3 | 4 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True' 5 | 6 | intersphinx_mapping = { 7 | 'http://docs.python.org': None, 8 | } 9 | 10 | extensions = [ 11 | 'sphinx.ext.autodoc', 12 | 'sphinx.ext.intersphinx', 13 | ] 14 | 15 | # General 16 | source_suffix = '.rst' 17 | master_doc = 'index' 18 | project = 'fastapi_sqlalchemy' 19 | first_year = 2019 20 | current_year = datetime.datetime.now().year 21 | copyright = (str(current_year) if current_year==first_year else ('%s-%s'%(first_year,current_year)))+' Chris Withers' 22 | version = release = pkg_resources.get_distribution(project).version 23 | exclude_patterns = [ 24 | '_build' 25 | ] 26 | pygments_style = 'sphinx' 27 | 28 | # Options for HTML output 29 | html_theme = 'default' if on_rtd else 'sphinx_rtd_theme' 30 | htmlhelp_basename = project+'doc' 31 | 32 | # Options for LaTeX output 33 | latex_documents = [ 34 | ('index',project+'.tex', project+u' Documentation', 35 | 'Chris Withers', 'manual'), 36 | ] 37 | 38 | -------------------------------------------------------------------------------- /docs/development.rst: -------------------------------------------------------------------------------- 1 | Development 2 | =========== 3 | 4 | .. highlight:: bash 5 | 6 | The latest development version of the documentation can be found here: 7 | 8 | http://fastapi_sqlalchemy.readthedocs.org/en/latest/ 9 | 10 | If you wish to contribute to this project, then you should fork the 11 | repository found here: 12 | 13 | https://github.com/cjw296/fastapi_sqlalchemy/ 14 | 15 | Once that has been done and you have a checkout, you can follow these 16 | instructions to perform various development tasks: 17 | 18 | Setting up a virtualenv 19 | ----------------------- 20 | 21 | The recommended way to set up a development environment is to turn 22 | your checkout into a virtualenv and then install the package in 23 | editable form as follows:: 24 | 25 | $ virtualenv . 26 | $ bin/pip install -U -e .[test,build] 27 | 28 | Running the tests 29 | ----------------- 30 | 31 | Once you've set up a virtualenv, the tests can be run as follows:: 32 | 33 | $ bin/pytest 34 | 35 | Building the documentation 36 | -------------------------- 37 | 38 | The Sphinx documentation is built by doing the following from the 39 | directory containing setup.py:: 40 | 41 | $ source bin/activate 42 | $ cd docs 43 | $ make html 44 | 45 | To check that the description that will be used on PyPI renders properly, 46 | do the following:: 47 | 48 | $ python setup.py --long-description | rst2html.py > desc.html 49 | 50 | The resulting ``desc.html`` should be checked by opening in a browser. 51 | 52 | To check that the README that will be used on GitHub renders properly, 53 | do the following:: 54 | 55 | $ cat README.rst | rst2html.py > readme.html 56 | 57 | The resulting ``readme.html`` should be checked by opening in a browser. 58 | 59 | Making a release 60 | ---------------- 61 | 62 | To make a release, just update the version in ``setup.py``, 63 | update the change log, 64 | and push to https://github.com/cjw296/fastapi_sqlalchemy 65 | and Carthorse should take care of the rest. 66 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | 3 | .. toctree:: 4 | :maxdepth: 3 5 | 6 | use.rst 7 | api.rst 8 | development.rst 9 | changes.rst 10 | license.rst 11 | 12 | Indices and tables 13 | ================== 14 | 15 | * :ref:`genindex` 16 | * :ref:`modindex` 17 | * :ref:`search` 18 | 19 | -------------------------------------------------------------------------------- /docs/license.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | License 3 | ======= 4 | 5 | .. literalinclude:: ../LICENSE.rst 6 | -------------------------------------------------------------------------------- /docs/use.rst: -------------------------------------------------------------------------------- 1 | .. py:currentmodule:: fastapi_sqlalchemy 2 | 3 | Using FastAPI tools for SQLAlchemy 4 | ================================== 5 | 6 | 7 | Installation 8 | ~~~~~~~~~~~~ 9 | 10 | FastAPI tools for SQLAlchemy is available on the `Python Package Index`__ and can be installed 11 | with any tools for managing Python environments. 12 | 13 | __ https://pypi.org 14 | -------------------------------------------------------------------------------- /fastapi_sqlalchemy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjw296/fastapi_sqlalchemy/980ee1570b2a872bc4be136355c58ec399186d4c/fastapi_sqlalchemy/__init__.py -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # See license.txt for license details. 2 | # Copyright (c) 2019, Chris Withers 3 | 4 | import os 5 | 6 | from setuptools import setup, find_packages 7 | 8 | base_dir = os.path.dirname(__file__) 9 | 10 | setup( 11 | name='fastapi_sqlalchemy', 12 | version='0.0.0.dev0', 13 | author='Chris Withers', 14 | author_email='chris@withers.org', 15 | license='MIT', 16 | description=( 17 | "Tools to allow FastAPI and SQLAlchemy to work better together, particularly when it comes to pydantic." 18 | ), 19 | long_description=open('README.rst').read(), 20 | url='https://github.com/cjw296/fastapi_sqlalchemy', 21 | classifiers=[ 22 | 'License :: OSI Approved :: MIT License', 23 | 'Programming Language :: Python :: 3', 24 | 'Programming Language :: Python :: 3.6', 25 | 'Programming Language :: Python :: 3.7', 26 | ], 27 | packages=find_packages(exclude=["tests"]), 28 | zip_safe=False, 29 | include_package_data=True, 30 | extras_require=dict( 31 | test=[ 32 | 'pytest', 33 | 'pytest-cov', 34 | 'sybil', 35 | 'testfixtures', 36 | ], 37 | build=['sphinx', 'sphinx-rtd-theme', 'setuptools-git', 'twine', 'wheel'] 38 | ), 39 | ) 40 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjw296/fastapi_sqlalchemy/980ee1570b2a872bc4be136355c58ec399186d4c/tests/__init__.py --------------------------------------------------------------------------------