Code Monkey home page Code Monkey logo

py-fastapi-library-management-api's Introduction

Library Management API

Task

Create a Simple Library Management API

Objective

You should develop a basic library management API using FastAPI and SQLAlchemy ORM with SQLite as the database.

Requirements

  1. Set up the project structure with the following files:
- main.py
- database.py
- models.py
- schemas.py
- crud.py
  1. Set up a SQLite database connection in the database.py file.

  2. Create SQLAlchemy models for 'Author' and 'Book' in the models.py file.

  3. The 'Author' model should have the following fields:

- id (integer, primary key)
- name (string, unique)
- bio (string)
- books (relationship with the 'Book' model, one-to-many)
  1. The 'Book' model should have the following fields:
- id (integer, primary key)
- title (string)
- summary (string)
- publication_date (date)
- author_id (foreign key referencing 'Author' model)
  1. Create Pydantic models for data validation and serialization in the schemas.py file.

  2. Create CRUD utility functions for authors and books in the crud.py file.

  3. In the main.py file, integrate the parts created in previous steps to build the FastAPI application:

    • Create the database tables using the SQLAlchemy models.
    • Define the FastAPI application object.
    • Create a dependency function to manage database sessions.
    • Implement API endpoints for the following actions:
      • Create a new author.
      • Retrieve a list of authors with pagination (skip, limit).
      • Retrieve a single author by ID.
      • Create a new book for a specific author.
      • Retrieve a list of books with pagination (skip, limit).
      • Filter books by author ID.

Upon completion, you should have a functional library management API that allows the user to manage authors and their books.

py-fastapi-library-management-api's People

Contributors

danylott avatar

Stargazers

 avatar

Watchers

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