GithubHelp home page GithubHelp logo

scraiber / fastapi-db-example Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

Example FastAPI project to connect to various DBs (PostgreSQL, Redis, S3) and CRUD operations for each of them

License: MIT License

Dockerfile 3.48% Python 96.52%
circleci docker-compose fastapi fastapi-boilerplate fastapi-crud fastapi-docker fastapi-sqlalchemy fastapi-template minio redis s3 sqlalchemy sqlalchemy-python sqlmodel

fastapi-db-example's Introduction

FastAPI example project for DB connections

In this repo, we have a FastAPI example project that

  • you can develop with Docker and docker-compose
  • connects to a PostgreSQL database with SQLModel and sqlalchemy with CRUD operations examples
  • connects to Redis with CRUD operations examples
  • connects to S3 with CRUD operations examples
  • has basic unit tests
  • has a simple CI pipeline yaml file for CircleCI

How to develop it?

Spin up docker-compose

$ docker-compose up -d --build

Now under localhost:8004/docs, you can find the APIs.

Tests

With

$ docker-compose exec web pytest .

you can run the tests and with something like

$ docker-compose exec web pytest tests/test_user.py

you can run specific tests, in this case for the rights endpoints of the API.

Use docker-compose logs web to check the logs of the FastAPI server.

To bring the docker containers down, simply run

$ docker-compose down -v

Push to Docker Hub

You can use something analogous to the following to push the image to Docker Hub:

docker build -f src/Dockerfile -t scraiber/fastapi-db-example:v1.0.0 .
docker push scraiber/fastapi-db-example:v1.0.0

Setup PyCharm virtual environment (for Python 3.12)

First, create a virtual environment for Python 3.12. Then run

python3.12 -m ensurepip --upgrade
python3.12 -m pip install --upgrade setuptools

in the terminal. After this, you can install the packages in requirements.txt.

fastapi-db-example's People

Contributors

junoriosity 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.