Posts

Showing posts from February, 2025

Python: Creating REST APIs using Flask and SQLAlchemy

Image
In the previous article , I covered database access from the Python application using the SQLAlchemy package. In this article, we will implement the REST APIs in Python using the Flask framework.  What is Flask? Flask is a popular microweb framework that is written in Python. It is designed to be lightweight and modular, which makes it easy to create web applications quickly. It provides all those essentials needed to build a web app, such as routing, request handling, and templates while allowing developers the freedom to choose additional libraries and tools based on their needs. Following are some of the important Flask objects: The request Object The request object in Flask is used to handle incoming request data. This contains all the data sent by the client in an HTTP request including form data, query parameters, headers, cookies, etc. Following are some common attributes and methods of the request object: request.method : The HTTP method used for the request (e.g., GET, P...

Python: Using SQLAlchemy to perform database operations

Image
In this article, we will see a simple approach for performing database operations using SqlAlchemy in Python programming language. Python is a versatile and very powerful programming language that is widely used in various fields such as web development, data analysis, artificial intelligence, scientific computing, automation, etc. While working on any of the fields in Python, we need to access the database and perform operations on it. It is highly recommended that the database operations should be performed using a very powerful database access object model. This is where SQLAlchemy comes into the picture. SQLAlchemy is a powerful SQL toolkit and Object-Relational Mapping (ORM) library for Python. It provides a flexible and efficient way to interact with relational databases using Python objects.  I t provides a full suite of enterprise-level persistence patterns, designed for efficient and high-performing database access   To understand and implement the code for this arti...