The Wayback Machine - https://web.archive.org/web/20240603083614/https://www.geeksforgeeks.org/python-database-tutorial/
Open In App

Python Database Tutorial

Last Updated : 15 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
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.

Python Database Tutorial

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. 

Introduction

Python MySQL Queries

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.

Introduction

Python SQLite Queries

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.

Introduction

Python JSON – Reading and Writing

Parsing JSON

Python JSON – Serializing and Deserializing

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

Introduction

Python MongoDB Queries

Python MongoDB Indexing



Similar Reads

Python MySQL - Create Database
Python Database API ( Application Program Interface ) is the Database interface for the standard Python. This standard is adhered to by most Python Database interfaces. There are various Database servers supported by Python Database such as MySQL, GadFly, mSQL, PostgreSQL, Microsoft SQL Server 2000, Informix, Interbase, Oracle, Sybase etc. To conne
2 min read
How to Create a Backup of a SQLite Database using Python?
In this article, we will learn How to Create a Backup of an SQLite Database using Python. To Create a Backup of an SQLite Database using Python, the required modules are SQLite3 and IO. First, let's create the original database to do that follow the below program: C/C++ Code import sqlite3 import io from sqlite3 import Error def SQLite_connection()
2 min read
Oracle Database Connection in Python
Sometimes as part of programming, we are required to work with databases because we want to store a huge amount of information so we use databases, such as Oracle, MySQL, etc. So In this article, we will discuss the connectivity of Oracle database using Python. This can be done through the module name cx_Oracle. Oracle Database: For communicating w
6 min read
Inserting variables to database table using Python
In this article, we will see how one can insert the user data using variables. Here, we are using the sqlite module to work on a database but before that, we need to import that package. import sqlite3 To see the operation on a database level just download the SQLite browser database.Note: For the demonstration, we have used certain values but you
3 min read
Python | Database management in PostgreSQL
PostgreSQL is an open source object-relational database management system. It is well known for its reliability, robustness, and performance. PostgreSQL has a variety of libraries of API (Application programmable interface) that are available for a variety of popular programming languages such as Python. It provides a lot of features for Database m
6 min read
Connect MySQL database using MySQL-Connector Python
While working with Python we need to work with databases, they may be of different types like MySQL, SQLite, NoSQL, etc. In this article, we will be looking forward to how to connect MySQL databases using MySQL Connector/Python.MySQL Connector module of Python is used to connect MySQL databases with the Python programs, it does that using the Pytho
2 min read
Create a database in MongoDB using Python
MongoDB is a general-purpose, document-based, distributed database built for modern application developers and the cloud. It is a document database, which means it stores data in JSON-like documents. This is an efficient way to think about data and is more expressive and powerful than the traditional table model. MongoDB has no separate command to
2 min read
Create MySQL Database Login Page in Python using Tkinter
Prerequisites: Python GUI – tkinter, Python MySQL – Select QueryTkinter is one of the Python libraries which contains many functions for the development of graphic user interface pages and windows. Login pages are important for the development of any kind of mobile or web application. This page is most essential for user authentication purposes.We
2 min read
Make Python API to access Mongo Atlas Database
Prerequisite: Python | Build a REST API using Flask RESTful APIs are a very helpful tool to manage the backend of an application. It can be used to define the architecture as well as manage the dependencies of the application using routes managed by the API. Flask is a popular micro framework for building web applications. In this article, we will
6 min read
Python - Database Manager (dbm) package
In this article, we will learn about dbm, a package in the built-in library of Python. The dbm package in Python provides a simple dictionary-like interface of the form DBM (DataBase Manager) generally used in the Unix operating system. dbm stores data in simple key-value pair form like a dictionary, making it easier to insert, edit and retrieve da
4 min read
Practice Tags :