Python Database Tutorial Last Updated : 15 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Python being a high-level language provides support for various databases. We can connect and run queries for a particular database using Python and without writing raw queries in the terminal or shell of that particular database, we just need to have that database installed in our system. In this tutorial, we will discuss how to Python with the most commonly used relational databases such as MySQL, SQLite, NoSQL databases like MongoDB and we will also discuss how to deal with JSON using Python with the help of good examples. Python MySQL Python MySQL Connector is a Python driver that helps to integrate Python and MySQL. This Python MySQL library allows the conversion between Python and MySQL data types. MySQL Connector API is implemented using pure Python and does not require any third-party library. IntroductionInstall Python MySQL connector MySQL-Connector-Python module in Python Connect MySQL database using MySQL-Connector Python Python MySQL QueriesPython MySQL – Create Database Python: MySQL Create Table Python MySQL – Insert into Table Python MySQL – Select Query Python MySQL – Where Clause Python MySQL – Order By Clause Python MySQL – Delete Query Python MySQL – Drop Table Python MySQL – Update Query Python MySQL – Limit Clause Python MySQL – Join Commit & RollBack Operation in Python Note: For more information, refer to our detailed Python MySQL Tutorial Python SQLite Python SQLite3 module is used to integrate the SQLite database with Python. It is a standardized Python DBI API 2.0 and provides a straightforward and simple-to-use interface for interacting with SQLite databases. There is no need to install this module separately as it comes along with Python after the 2.5x version. IntroductionIntroduction to SQLite in PythonPython SQLite – Connecting to DatabaseSQLite Datatypes and its Corresponding Python TypesPython SQLite QueriesPython SQLite – Cursor ObjectPython SQLite – Create TablePython SQLite – Insert DataPython SQLite – Select Data from TablePython SQLite – WHERE ClausePython SQLite – ORDER BY ClausePython SQLite – LIMIT ClausePython SQLite – JOIN ClausePython SQLite – Deleting Data in TablePython SQLite – DROP TablePython SQLite – Update DataPython SQLite – Update Specific Column Note: For more information, refer to our detailed Python SQLite3 Tutorial Python JSON JSON JavaScript Object Notation is a format for structuring data. It is mainly used for storing and transferring data between the browser and the server. Python too supports JSON with a built-in package called json. This package provides all the necessary tools for working with JSON Objects including parsing, serializing, deserializing, and many more. IntroductionWhat is JSON?Data types in JSONWorking With JSON Data in PythonPython JSON - Reading and WritingReading and Writing JSON to a File in PythonAppend to JSON file using PythonParsing JSONHow to Parse Data From JSON into Python?How To Convert Python Dictionary To JSON?Python – Convert JSON to stringWays to convert string to json objectConvert JSON data Into a Custom Python ObjectPython JSON - Serializing and DeserializingSerializing JSON in Pythonjson.dump() in Pythonjson.dumps() in PythonPython – Difference between json.dump() and json.dumps()Deserialize JSON to Object in Pythonjson.load() in Pythonjson.loads() in PythonDifference Between json.load() and json.loads()Encoding and Decoding Custom Objects in Python-JSONSerialize and Deserialize complex JSON in PythonPython MongoDB MongoDB is one of the most popular NoSQL database. It is a cross-platform, object-oriented database. Basically NoSQL means MongoDB does not store data in the table or relational format rather provide a different mechanism for storage and retrieval of data. This is called BSON which is similar to JSON. That’s why MongoDB offers high speed, high availability, and high scalability. IntroductionMongoDB and PythonGuide to Install MongoDB with Python | WindowsWhat is a PyMongo Cursor?Create a database in MongoDB using PythonPython MongoDB QueriesWhat is a MongoDB Query?Insert and Update Data Queryinsert_one Queryinsert_many QueryDifference Between insert, insert_one, and insert_many queries in PymongoUpdate_one QueryUpdate_many Queryinsert, replace_one, replace_many QueriesDelete Data and Drop CollectionDelete_one QueryDelete_many QueryFind Queryfind_one Queryfind_one_and_update Queryfind_one_and_delete queryfind_one_and_replace QuerySort Querydistinct Queryrename Querybulk_write Query$group (aggregation) OperationLimit QueryNested Queries in PyMongoPython MongoDB IndexingIndexing in MongoDB using PythonPython MongoDB – create_index QueryHow to create index for MongoDB Collection using Python?Get all the information of a Collection’s indexes using PyMongodrop_index QueryHow to Drop all the indexes in a Collection using PyMongo?How to rebuild all the indexes of a collection using PyMongo? Comment More infoAdvertise with us Next Article How to Connect Python with SQL Database? abhishek1 Follow Improve Article Tags : Python Python-database Tutorials Practice Tags : python Similar Reads Python Database Tutorial Python being a high-level language provides support for various databases. We can connect and run queries for a particular database using Python and without writing raw queries in the terminal or shell of that particular database, we just need to have that database installed in our system. In this t 4 min read How to Connect Python with SQL Database? In this article, we will learn how to connect SQL with Python using the MySQL Connector Python module. Below diagram illustrates how a connection request is sent to MySQL connector Python, how it gets accepted from the database and how the cursor is executed with result data.SQL connection with Pyth 2 min read SQL using Python In this article, integrating SQLite3 with Python is discussed. Here we will discuss all the CRUD operations on the SQLite3 database using Python. CRUD contains four major operations - Note: This needs a basic understanding of SQL. Here, we are going to connect SQLite with Python. Python has a nati 7 min read Python MySQL Python MySQL Connector is a Python driver that helps to integrate Python and MySQL. This Python MySQL library allows the conversion between Python and MySQL data types. MySQL Connector API is implemented using pure Python and does not require any third-party library. This Python MySQL tutorial will 9 min read Python SQLite Python SQLite3 module is used to integrate the SQLite database with Python. It is a standardized Python DBI API 2.0 and provides a straightforward and simple-to-use interface for interacting with SQLite databases. There is no need to install this module separately as it comes along with Python after 4 min read Python MongoDB Tutorial MongoDB is a popular NoSQL database designed to store and manage data flexibly and at scale. Unlike traditional relational databases that use tables and rows, MongoDB stores data as JSON-like documents using a format called BSON (Binary JSON). This document-oriented model makes it easy to handle com 2 min read Introduction to Psycopg2 module in Python Psycopg is the most popular PostgreSQL adapter used in  Python.  Its works on the principle of the whole implementation of Python DB API 2.0 along with the thread safety (the same connection is shared by multiple threads). It is designed to perform heavily multi-threaded applications that usually cr 4 min read Top 7 Databases to Learn in 2025 A database is just like a room in an office where all the files and important information can be stored related to a project. Every company needs a database to store and organize the information. The information that we store can be very sensitive, so we always have to be careful while accessing or 10 min read Interface Python with an SQL Database Python is an easy-to-learn language and connectivity of python with any SQL database is a much-desired option to have the persistence feature. Python is an object-oriented programming language and it is open source. Newcomers to the software industry including school children too can learn Python ea 8 min read Access Relation Databases with Python Databases are powerful tools for data scientists. DB-API is Python's standard API used for accessing databases. It allows you to write a single program that works with multiple kinds of relational databases instead of writing a separate program for each one. This is how a typical user accesses datab 3 min read Like