Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Up package version #123

Merged
merged 7 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion df_to_azure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .export import df_to_azure

__version__ = "0.8.1"
__version__ = "0.9.0"

logging.basicConfig(
format="%(asctime)s.%(msecs)03d [%(levelname)-5s] [%(name)s] - %(message)s",
Expand Down
4 changes: 2 additions & 2 deletions df_to_azure/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def create_stored_procedure(self):
)


def auth_azure():
def auth_azure(driver: str = "ODBC Driver 17 for SQL Server"):

connection_string = "mssql+pyodbc://{}:{}@{}:1433/{}?driver={}".format(
os.environ.get("SQL_USER"),
quote_plus(os.environ.get("SQL_PW")),
os.environ.get("SQL_SERVER"),
os.environ.get("SQL_DB"),
"ODBC Driver 17 for SQL Server",
driver,
)
con = create_engine(connection_string).connect()

Expand Down
2 changes: 1 addition & 1 deletion df_to_azure/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def upload_to_blob(self):
blob=f"{self.table_name}/{self.table_name}.csv",
)

data = self.df.to_csv(index=False, sep="^", quotechar='"', line_terminator="\n")
data = self.df.to_csv(index=False, sep="^", quotechar='"', lineterminator="\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note: Ive created e a new issue #125 for making this an export to .parquet.

blob_client.upload_blob(data, overwrite=True)

def create_schema(self):
Expand Down
32 changes: 9 additions & 23 deletions df_to_azure/tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ def test_pipeline_name():
def test_empty_dataframe():
df = DataFrame()

with pytest.raises(SystemExit):
df_to_azure(
df=df,
tablename="empty_dataframe",
schema="test",
method="create",
wait_till_finished=True,
)
adf_client, run_response = df_to_azure(
df=df,
tablename="empty_dataframe",
schema="test",
method="create",
wait_till_finished=True,
)
assert adf_client is None
assert run_response is None


def test_convert_bigint():
Expand Down Expand Up @@ -203,18 +204,3 @@ def test_double_column_names():
schema="test",
wait_till_finished=True,
)


def test_dataframe_with_no_data():

# scenario where there are 2 dataframes, first one empty and the second one with data.
df_list = [DataFrame(), DataFrame({"A": [1, 2, 3], "B": [10, 20, 30], "C": ["X", "Y", "Z"]})]

results = list()

for df in df_list:
r = df_to_azure(df, tablename=f"dataset_{df.shape[0]}_records", schema="test")
results.append(r)

# there should be 2 results from the 2 df_to_azure operations.
assert len(results) == 2
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
azure-identity~=1.7.1
azure-mgmt-datafactory~=2.2.0
azure-mgmt-resource~=20.1.0
azure-storage-blob~=12.8.1
pandas~=1.4.1
pyarrow~=7.0.0
pyodbc~=4.0.32
sqlalchemy~=1.4.31
azure-identity>=1.7.1
azure-mgmt-datafactory>=2.2.0,<2.7.0
azure-mgmt-resource>=20.1.0
azure-storage-blob>=12.8.1
pandas>=1.4.1
pyarrow>=7.0.0
pyodbc>=4.0.32
sqlalchemy>=1.4.31,<2.0.0
19 changes: 10 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = df_to_azure
version = 0.8.1
version = 0.9.0
author = Melvin Folkers, Erfan Nariman
author_email = melvin@zypp.io, erfan@zypp.io
description = Automatically write pandas DataFrames to SQL by creating pipelines in Azure Data Factory with copy activity from blob to SQL
Expand All @@ -20,14 +20,15 @@ classifiers =
packages = df_to_azure
python_requires = >=3.7
install_requires =
azure-identity~=1.7.1
azure-mgmt-datafactory~=2.2.0
azure-mgmt-resource~=20.1.0
azure-storage-blob~=12.8.1
pandas~=1.4.1
pyarrow~=7.0.0
pyodbc~=4.0.32
sqlalchemy~=1.4.31
azure-identity>=1.7.1
azure-mgmt-datafactory>=2.2.0,<2.7.0
azure-mgmt-resource>=20.1.0
azure-storage-blob>=12.8.1
pandas>=1.4.1
pyarrow>=7.0.0
pyodbc>=4.0.32
sqlalchemy>=1.4.31,<2.0.0



[flake8]
Expand Down