GithubHelp home page GithubHelp logo

aaron-beach / fastapi-realworld-example-app-mysql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiaozl/fastapi-realworld-example-app-mysql

0.0 1.0 0.0 91 KB

python fastapi example connection to mysql

License: MIT License

Dockerfile 0.39% Python 96.91% TSQL 1.30% Shell 1.40%

fastapi-realworld-example-app-mysql's Introduction

image

image

image

image

image

image

image

Quickstart

Then run the following commands to bootstrap your environment with poetry: :

git clone https://github.com/xiaozl/fastapi-realworld-example-app-mysql.git
cd fastapi-realworld-example-app-mysql
poetry install
poetry shell

Then create .env file (or rename and modify .env.example) in project root and set environment variables for application: :

HOST=mysql host  127.0.0.1 
PORT=mysql port 3306 
USER=mysql user root
PWD=mysql pwd root
DB=mysql db fastapi

To run the web application in debug use init mysql db: :

uvicorn app.main:app --reload

Deployment with Docker

You must have docker and docker-compose tools installed to work with material in this section. First, create .env file like in Quickstart section or modify .env.example. POSTGRES_HOST must be specified as db or modified in docker-compose.yml also. Then just run:

docker-compose up -d db
docker-compose up -d app

Application will be available on localhost in your browser.

Web routes

All routes are available on /docs or /redoc paths with Swagger or ReDoc.

Project structure

Files related to application are in the app or tests directories. Application parts are:

app
├── api              - web related stuff.
│   ├── dependencies - dependencies for routes definition.
│   ├── errors       - definition of error handlers.
│   └── routes       - web routes.
├── core             - application configuration, startup events, logging.
├── db               - db related stuff.
│   ├── migrations   - manually written alembic migrations.
│   └── repositories - all crud stuff.
├── models           - pydantic models for this application.
│   ├── domain       - main models that are used almost everywhere.
│   └── schemas      - schemas for using in web routes.
├── resources        - strings that are used in web responses.
├── services         - logic that is not just crud related.
└── main.py          - FastAPI application creation and configuration.

fastapi-realworld-example-app-mysql's People

Contributors

xiaozl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.