{"id":106465,"date":"2021-12-28T11:00:00","date_gmt":"2021-12-28T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=106465"},"modified":"2021-12-22T15:42:49","modified_gmt":"2021-12-22T13:42:49","slug":"crud-operations-using-python-fastapi","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/","title":{"rendered":"CRUD Operations using Python FastAPI"},"content":{"rendered":"<p>Hello in this tutorial, we will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.<\/p>\n<h2>1. Introduction<\/h2>\n<p><strong>FastAPI<\/strong> is a fast and high-performance web framework for building api with python 3.6+. It offers many features like:&nbsp;<\/p>\n<ul>\n<li>High performance<\/li>\n<li>Automatic interactive code generation<\/li>\n<li>Offers great editor support and documentation<\/li>\n<\/ul>\n<h3>1.1 SQLite<\/h3>\n<p><strong>SQLite<\/strong> is a software library that provides a relational database management system. It is lightweight in terms of setup, database administration, and required resources. It is self-contained, serverless, zero-configuration, transactional.<\/p>\n<ul>\n<li>Self-contained means that it require minimal support from the operating system or any external library<\/li>\n<li>Zero-configuration means that no external installation is required before using it<\/li>\n<li>Transactional means it is fully ACID-compliant i.e. all queries and changes are atomic, consistent, isolated, and durable<\/li>\n<\/ul>\n<h3>1.2 Setting up Python<\/h3>\n<p>If someone needs to go through the Python installation on Windows, please watch <a href=\"https:\/\/www.youtube.com\/watch?v=i-MuSAwgwCU\" target=\"_blank\" rel=\"noopener\">this<\/a> link. You can download the Python from <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">this<\/a> link.<\/p>\n<h2>2. CRUD Operations using Python FastAPI<\/h2>\n<p>I am using <a href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\" rel=\"noopener\">JetBrains PyCharm<\/a> as my preferred IDE. You&#8217;re free to choose the IDE of your choice. Fig. 1 represents the project structure for this tutorial.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectstructure-img1.jpg\"><img decoding=\"async\" width=\"482\" height=\"148\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectstructure-img1.jpg\" alt=\"crud Python FastAPI - app structure\" class=\"wp-image-106466\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectstructure-img1.jpg 482w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectstructure-img1-300x92.jpg 300w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/a><figcaption>Fig. 1: Application structure<\/figcaption><\/figure>\n<\/div>\n<p>The file named &#8211; <code>movie_database.db<\/code> will be generated dynamically during the application run.<\/p>\n<h3>2.1 Creating a requirements file<\/h3>\n<p>Add the below code to the requirements file. The file will be responsible to download and install the packages required for this tutorial.<\/p>\n<p><span style=\"text-decoration: underline\"><em>requirements.txt<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">fastapi\nsqlalchemy\npydantic\n<\/pre>\n<h3>2.2 Creating the database config<\/h3>\n<p>Create the database configuration file. The file will be responsible for handling the SQLite database and interacting with the <code>movie<\/code> database.<\/p>\n<p><span style=\"text-decoration: underline\"><em>db_handler.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># Handling database\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nDATABASE_URL = \"sqlite:\/\/\/.\/movie_database.db\"\n\n# creating engine\n# Setting check_same_thread to False so that the returned connection may be shared across multiple threads\nengine = create_engine(DATABASE_URL, connect_args={\"check_same_thread\": False})\n\n# bind \u2013 An optional Connectable, will assign the bind attribute on the MetaData instance\nSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n# A simple constructor that allows initialization\nBase = declarative_base()\n<\/pre>\n<h3>2.3 Creating the model class<\/h3>\n<p>Create the model class responsible for creating the table structure.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline\"><em>model.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># Model class\nfrom sqlalchemy import Boolean, Column, Integer, String\n\nfrom db_handler import Base\n\n\nclass Movies(Base):\n    # Setting constraints on the table structure\n    __tablename__ = \"movie\"\n    id = Column(Integer, primary_key=True, autoincrement=True, index=True, nullable=False)\n    movie_id = Column(String)\n    movie_name = Column(String(255))\n    director = Column(String(100))\n    geners = Column(String)\n    membership_required = Column(Boolean)\n    cast = Column(String(255))\n    streaming_platform = Column(String)\n<\/pre>\n<h3>2.4 Creating the schema class<\/h3>\n<p>Create the schema class responsible for creating the schema and use it during the crud operations.<\/p>\n<p><span style=\"text-decoration: underline\"><em>schema.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># Schema class\nfrom typing import Optional\n\nfrom pydantic import BaseModel\n\n\nclass MovieBase(BaseModel):\n    movie_name: str\n    director: str\n    geners: str\n    cast: str\n\n\nclass MovieAdd(MovieBase):\n    movie_id: int\n    # Optional[str] is just a shorthand or alias for Union[str, None].\n    streaming_platform: Optional[str] = None\n    membership_required: bool\n\n    # Behaviour of pydantic can be controlled via the Config class on a model\n    # to support models that map to ORM objects. Config property orm_mode must be set to True\n    class Config:\n        orm_mode = True\n\n\nclass Movie(MovieAdd):\n    id: int\n\n    # Behaviour of pydantic can be controlled via the Config class on a model\n    # to support models that map to ORM objects. Config property orm_mode must be set to True\n    class Config:\n        orm_mode = True\n\n\nclass UpdateMovie(BaseModel):\n    # Optional[str] is just a shorthand or alias for Union[str, None].\n    streaming_platform: Optional[str] = None\n    membership_required: bool\n\n    # Behaviour of pydantic can be controlled via the Config class on a model\n    # to support models that map to ORM objects. Config property orm_mode must be set to True\n    class Config:\n        orm_mode = True\n<\/pre>\n<h3>2.5 Creating the crud class<\/h3>\n<p>Create the crud class responsible for performing the sql operations.<\/p>\n<p><span style=\"text-decoration: underline\"><em>crud.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\">#  Crud operation methods\nfrom sqlalchemy.orm import Session\n\nimport model\nimport schema\n\n\ndef get_all(db: Session):\n    print(\"fetching records\")\n    return db.query(model.Movies).all()\n\n\ndef get_by_id(db: Session, sl_id: int):\n    print(\"fetching record id={}\".format(sl_id))\n    return db.query(model.Movies).filter(model.Movies.id == sl_id).first()\n\n\ndef add(db: Session, movie: schema.MovieAdd):\n    mv_details = model.Movies(\n        movie_id=movie.movie_id,\n        movie_name=movie.movie_name,\n        director=movie.director,\n        geners=movie.geners,\n        membership_required=movie.membership_required,\n        cast=movie.cast,\n        streaming_platform=movie.streaming_platform)\n    print(\"saving new record\")\n    db.add(mv_details)\n    db.commit()\n    db.refresh(mv_details)\n    return model.Movies(**movie.dict())\n\n\ndef delete(db: Session, sl_id: int):\n    try:\n        print(\"deleting record id={}\".format(sl_id))\n        db.query(model.Movies).filter(model.Movies.id == sl_id).delete()\n        db.commit()\n    except Exception as e:\n        raise Exception(e)\n\n\ndef update(db: Session, sl_id: int, details: schema.UpdateMovie):\n    print(\"updating record id={}\".format(sl_id))\n    db.query(model.Movies).filter(model.Movies.id == sl_id).update(vars(details))\n    db.commit()\n    return db.query(model.Movies).filter(model.Movies.id == sl_id).first()\n<\/pre>\n<h3>2.6 Creating the application class<\/h3>\n<p>Create the application controller responsible for handling the incoming requests from the user and interact with the database to show the results.<\/p>\n<p><span style=\"text-decoration: underline\"><em>application.py<\/em><\/span><\/p>\n<pre class=\"brush:python;\"># Main class\nfrom typing import List\n\nfrom fastapi import Depends, FastAPI, HTTPException\nfrom sqlalchemy.orm import Session\n\nimport crud\nimport model\nimport schema\nfrom db_handler import SessionLocal, engine\n\nmodel.Base.metadata.create_all(bind=engine)\n\n# Initializing the app\napp = FastAPI(title=\"CRUD Operations using Python FastAPI\")\n\n\n# Database dependency\ndef get_db():\n    db = SessionLocal()\n    try:\n        yield db\n    finally:\n        db.close()\n\n\n# Get all movies\n@app.get('\/get-all', response_model=List[schema.Movie])\ndef get_all(db: Session = Depends(get_db)):\n    return crud.get_all(db=db)\n\n\n# Save new movie\n@app.post('\/add', response_model=schema.MovieAdd)\ndef add(movie: schema.MovieAdd, db: Session = Depends(get_db)):\n    movie_id = crud.get_by_id(db=db, sl_id=movie.movie_id)\n    if movie_id:\n        print(\"Resource conflict\")\n        raise HTTPException(status_code=409, detail=f\"Resource id {movie_id} already exist\")\n\n    return crud.add(db=db, movie=movie)\n\n\n# Delete a movie by id\n@app.delete('\/delete')\ndef delete(sl_id: int, db: Session = Depends(get_db)):\n    details = crud.get_by_id(db=db, sl_id=sl_id)\n    if not details:\n        print(\"Entity not found\")\n        raise HTTPException(status_code=404, detail=f\"Resource not found\")\n    try:\n        crud.delete(db=db, sl_id=sl_id)\n    except Exception as e:\n        raise HTTPException(status_code=400, detail=f\"Unable to delete: {e}\")\n\n    return {\"status\": \"accepted\", \"code\": \"202\", \"message\": \"Resource deleted\"}\n\n\n# Update a movie by id\n@app.put('\/update', response_model=schema.Movie)\ndef update(sl_id: int, update_param: schema.UpdateMovie, db: Session = Depends(get_db)):\n    details = crud.get_by_id(db=db, sl_id=sl_id)\n    if not details:\n        print(\"Entity not found\")\n        raise HTTPException(status_code=404, detail=f\"Resource not found\")\n\n    return crud.update(db=db, details=update_param, sl_id=sl_id)\n\n\n# Driver code\nif __name__ == '__main__':\n    import uvicorn\n\n    uvicorn.run(app, host=\"localhost\", port=7001, log_level=\"debug\")\n<\/pre>\n<h2>3. Run the application<\/h2>\n<p>Run the <code>application.py<\/code> python script once the code is completed and if everything goes well the application will be started on the port number &#8211; <code>7001<\/code> as shown in the below logs.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Application logs<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">INFO:     Started server process [44004]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\nINFO:     Uvicorn running on http:\/\/localhost:7001 (Press CTRL+C to quit)\n<\/pre>\n<h2>4. Demo<\/h2>\n<p>Open up the browser of your choice and hit the swagger documentation endpoint generated via the FastAPI. The documentation will list the endpoints created above.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Documentation endpoint<\/em><\/span><\/p>\n<pre class=\"brush:plain;\">http:\/\/localhost:7001\/docs\n<\/pre>\n<p>If everything goes well the documentation page will be shown as in Fig. 1 and you can use the endpoints to set up a playground for the application.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectdemo-img1.jpg\"><img decoding=\"async\" width=\"651\" height=\"425\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectdemo-img1.jpg\" alt=\"crud Python FastAPI - swagger doc\" class=\"wp-image-106467\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectdemo-img1.jpg 651w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/python-sqlite-crud-fastapi-projectdemo-img1-300x196.jpg 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><figcaption>Fig. 2: Swagger documentation<\/figcaption><\/figure>\n<\/div>\n<p>That is all for this tutorial and I hope the article served you with whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>5. Summary<\/h2>\n<p>In this tutorial, we learned about the SQLite sqlalchemy crud operation and implemented the FastAPI framework to quickly set up our application. You can download the source code of this tutorial from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>6. Download the Project<\/h2>\n<p>This was a tutorial on how to implement CRUD operations using the FastAPI framework.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/12\/CRUD-Operations-using-Python-FastAPI.zip\"><strong>CRUD Operations using Python FastAPI<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello in this tutorial, we will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite. 1. Introduction FastAPI is a fast and high-performance web framework for building api with python 3.6+. It offers many features like:&nbsp; High performance Automatic interactive code generation Offers great editor support &hellip;<\/p>\n","protected":false},"author":119,"featured_media":99891,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46689],"tags":[1716,1055,1728],"class_list":["post-106465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-sql","tag-sqlite"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CRUD Operations using Python FastAPI - Examples Java Code Geeks<\/title>\n<meta name=\"description\" content=\"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CRUD Operations using Python FastAPI - Examples Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-28T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"CRUD Operations using Python FastAPI\",\"datePublished\":\"2021-12-28T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\"},\"wordCount\":537,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"keywords\":[\"python\",\"sql\",\"sqlite\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\",\"name\":\"CRUD Operations using Python FastAPI - Examples Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"datePublished\":\"2021-12-28T09:00:00+00:00\",\"description\":\"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"set python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/web-development\/python\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"CRUD Operations using Python FastAPI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CRUD Operations using Python FastAPI - Examples Java Code Geeks","description":"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/","og_locale":"en_US","og_type":"article","og_title":"CRUD Operations using Python FastAPI - Examples Java Code Geeks","og_description":"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.","og_url":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2021-12-28T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"CRUD Operations using Python FastAPI","datePublished":"2021-12-28T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/"},"wordCount":537,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","keywords":["python","sql","sqlite"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/","url":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/","name":"CRUD Operations using Python FastAPI - Examples Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","datePublished":"2021-12-28T09:00:00+00:00","description":"We will implement the CRUD operations using the FastAPI framework in Python. For the database, we will be using SQLite.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/02\/python-logo.jpg","width":150,"height":150,"caption":"set python"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/crud-operations-using-python-fastapi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/examples.javacodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"Python","item":"https:\/\/examples.javacodegeeks.com\/category\/web-development\/python\/"},{"@type":"ListItem","position":4,"name":"CRUD Operations using Python FastAPI"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/106465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=106465"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/106465\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/99891"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=106465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=106465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=106465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}