Python provides support for working with different databases, allowing us to connect to databases, run queries, and manage data using Python.
- Relational Databases store data in tables with rows and columns, such as MySQL and SQLite.
- Non-Relational Databases store data in flexible formats such as documents and key-value pairs, such as MongoDB.
- Connect to databases, run queries, and manage data using Python.
- Work with JSON data for storing and exchanging structured information.
MySQL
It connects Python applications with MySQL databases. It converts data between Python and MySQL types and does not require third-party libraries.
MySQL Basics
MySQL Queries
- Create Database
- Create Table
- Insert into Table
- Select Query
- Where Clause
- Order By Clause
- Delete Query
- Drop Table
- Update Query
- Limit Clause
- Join
- Commit & RollBack Operation in Python
Note: For more information, refer to our detailed Python MySQL Tutorial
SQLite
Provides a simple interface for connecting Python with SQLite databases. It comes built-in with Python, so no separate installation is required.
SQLite Basics
SQLite Queries
- Cursor Object
- Create Table
- Insert Data
- Select Data from Table
- WHERE Clause
- ORDER BY Clause
- LIMIT Clause
- JOIN Clause
- Deleting Data in Table
- DROP Table
- Update Data
- Update Specific Column
Note: For more information, refer to our detailed SQLite3 Tutorial
JSON
Format used to store and exchange structured data. Python provides the built-in json module for parsing, serializing, and deserializing JSON data.
JSON Basics
Reading and Writing
Parsing JSON
- Parssing Data
- Python Dictionary To JSON
- JSON to String
- String to JSON Object
- JSON Data into a Custom Python Object
Serializing and Deserializing
- Serializing JSON
- json.dump()
- json.dumps()
- Deserialize JSON to Object
- json.load()
- json.loads()
- Encoding and Decoding Custom Objects
Note: For more information, refer to Python JSON Tutorials
MongoDB
Popular NoSQL database that stores data in a flexible document-based format instead of tables. It uses BSON, a binary format similar to JSON, for storing and retrieving data.
MongoDB Basics
MongoDB Queries
- MongoDB Query
- Insert and Update
- Insert_one
- Insert_many
- Update_one
- Update_many
- Delete Data and Drop Collection
- Delete_one
- Delete_many
- Find
- Find_one
- Find_one_and_update
- Find_one_and_delete
- Find_one_and_replace
- Sort
- Distinct
- Rename
- Bulk_write
- Aggregation Operation
- Limit
- Nested Queries
MongoDB Indexing
- Indexing
- Create_index
- Index for MongoDB Collection
- Information Using Collection’s Indexes
- Drop_index
- Drop all the Indexes in a Collection
- Rebuild all the Indexes of a Collection
Note: For more information, refer to Python MongoDB Tutorial