Code Monkey home page Code Monkey logo

report-service's Introduction

report-service

This service performs statistical reporting for the project.

Connect Database

File Structure

└── src
    ├── __init__.py
    ├── crud.py
    ├── database.py
    ├── main.py
    ├── models.py
    └── schemas.py

Step by step Connect DB

  • Create a database URL for SQLAlchemy

  • Create the SQLAlchemy engine

  • Create a SessionLocal class

    • Each instance of the SessionLocal class will be a database session. The class itself is not a database session yet.
    • But once we create an instance of the SessionLocal class, this instance will be the actual database session.
  • Create a Base class.

    • Now we will use the function declarative_base() that returns a class.
    • Later we will inherit from this class to create each of the database models or classes (the ORM models):
  • Create the database models

    • Now let's see the file  sql_app/models.py.
    • Create SQLAlchemy models from the Base class
    • Create model attributes/columns
    • Create the relationships
  • Create the Pydantic models:

    • Now let's check the file  sql_app/schemas.py.
  • CRUD utils

    • Now let's see the file sql_app/crud.py.
    • Read Data.
    • Create Data
  • Main FastAPI app

  • About def vs async def

  • Migrations

  • Review all the files

  • run uvicorn src.main:app or uvicorn src.main:app --reload

report-service's People

Contributors

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