- Generally, we will prefer to store data in the cloud, Azure is one of the best cloud platforms to store data. In this blog, I explain how to copy data from Maria DB to Azure blob using python.
- Maria DB is an open-source database that is made up of an original MYSQL developer.
- Azure is a cloud platform which includes IAAS, SAAS, PAAS services used for analytics, storage purpose, networking, etc.
- The Azure storage account used to store data, text files, images, pdf’s, can be used for replying to queries of message processing.
- Azure Storage account is of 4 types (Azure blob,Azure table, Azure file,and Azure queue). Azure blob stores data in an unstructured format.
Fig1: Data copy from Maria DB to Azure Blob
- We are going to store the data created in Maria DB as a text file in Azure Blob.
- Maria DB
- Azure Account
- As we are going to store data in Azure Blob, we need to create an Azure storage account.
STEPS TO CREATE STORAGE ACCOUNT IN AZURE:
- STEP 1: Log into Azure Account
- STEP 2: Click on Storage Account on the Home page and click on “Add” to create a new storage account.
- STEP 3: Create a storage account as shown below and click on the Create button.
- STEP 4: Now open the storage account created and click on the container
STEP 5: Now click on Add to add a new container that stores data in the blob.
STEPS TO MOVE DATA FROM MARIA DB TO AZURE BLOB:
- STEP 1: Create a table in Maria DB as below:
- STEP 2: Execute below Python code to retrieve the tables from Maria DB.
- Packages to install while connecting to Maria DB:
pip install mariadb
- STEP 3: Execute the below Python code to move the data from the table created in Maria DB to Azure BLOB.
- Package to install while connecting to Azure Blob:
- pip install Azure-storage-blob==2.1.0
STEP 4: By executing the above code text file will be created in Azure blob as shown below, db.txt is the file got created:
- By following the above steps we can move easily data from Maria DB to Azure Blob using python.
- Purpose of the article – To migrate data from Maria DB to Cloud
- Intended Audience – Who are migrating data from Maria DB to Cloud
Contact for further details:
EPM Analytics Senior Analyst