Skip to main content

logo

DF to Azure

Python module for fast upload of pandas DataFrame to azure using automatic created pipelines in Azure Data Factory.

Introduction

The purpose of this project is to upload large datasets using Azure Data Factory combined with a Azure SQL Server. In steps the following process kicks off:

1. The data will be uploaded as a .csv file to Azure Blob storage.
2. A SQL Database table is prepared based on the parameters in the settings/yml/adf_settings.yml
3. A pipeline is created for uploading the .csv from the Blob storage into the SQL table.
4. The pipeline is triggered, so that the .csv file is bulk inserted into the SQL table.

How it works

Based on the following attributes, it is possible to bulk insert your dataframe into the SQL Database:

from df_to_azure import df_to_azure

df_to_azure(df=df, tablename="table_name", schema="schema", method="create", id_field="col_a")
  1. df: dataframe you wish to export
  2. tablename: desired name of the table
  3. schema: desired sql schema
  4. method: option for "create" "append" or "upsert"
  5. id_field: id field of the table. Necessary if 4 is set to True
Upsert / create or append

It is possible to upsert the SQL table with (new) records, if present in the dataframe you want to upload. Based on the id_field, the SQL table is being checked on overlapping values. If there are new records, the "old" records will be updated in the SQL table. The new records will be uploaded and appended to the current SQL table.

Settings

To use this module, you need to add the azure subscriptions settings and azure data factory settings to your environment variables. We recommend to work with .env files and load them in during runtime. But this is optional and they can be set as system variables as well. Use the following template when using .env

# --- ADF SETTINGS ---
# general run settings
create="False"

# data factory settings
rg_name : ""
rg_location: "westeurope"
df_name : ""

# blob settings
ls_blob_name : "Python Blob Linked Service"
ls_blob_account_name : ""
ls_blob_container_name : ""
ls_blob_account_key : ""

# SQL settings
ls_sql_name : "Python SQL Linked Service"
ls_sql_server_name: ""
ls_sql_database_name: ""
ls_sql_database_user: ""
ls_sql_database_password: ""

# pipeline settings
trigger : True

# --- AZURE SETTINGS ---
# azure credentials for connecting to azure subscription.
client_id : ""
secret : ""
tenant : ""
subscription_id : ""

Maintained by Zypp:


Testing

To run the test suite, use:

pytest df_to_azure

To run pytest for a single test:

pytest df_to_azure/tests/test_df_to_azure::test_duplicate_keys_upsert

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

df_to_azure-0.1.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

df_to_azure-0.1.3-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file df_to_azure-0.1.3.tar.gz.

File metadata

  • Download URL: df_to_azure-0.1.3.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.2

File hashes

Hashes for df_to_azure-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c939532a0b38d1b2c0d3ff487d6f3a205926b75b10cc8dc16717b1d8428a458e
MD5 b891870abef0ce1f8fdb038b3576243d
BLAKE2b-256 cb42f69626c8de7b8cce31bba3a754ae27aa0492b4935e77f0d737a0bb6f8596

See more details on using hashes here.

File details

Details for the file df_to_azure-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: df_to_azure-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.2

File hashes

Hashes for df_to_azure-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e3dfc26a87ffde6409dfb1e5e8e05efc40be21009ba221cd70a5934357d23a
MD5 3a234cabf0737e6de19bdc83885e279a
BLAKE2b-256 ada6167aa4aaa2941469faabf623c7222e054e497a64850f0a72a75b3d90ecf8

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.0

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.6.0

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page