Skip to main content
Version: 4.4

Connectors

Azure Blob Storage Connector - Get Dataโ€‹

Install packagesโ€‹

import os
os.system("pip install katonic[connectors]==1.6.2")

azure-blob-credentials.json

{
"ACCOUNT_NAME": "accountname",
"ACCOUNT_KEY": "accountkey",
"CONTAINER_NAME": "container_data",
"BLOB_NAME": "driver_data.csv"
}
# Define all your configurations inside a JSON file.
import json

with open('azure-blob-credentials.json') as f:
config = json.load(f)

Initializing the AzureBlobConnector with the provided credentials and configuration.

from katonic.connectors.python.azure_blob import AzureBlobConnector
df = AzureBlobConnector(
account_name=config["ACCOUNT_NAME"],
account_key=config["ACCOUNT_KEY"],
container_name=config["CONTAINER_NAME"],
blob_name=config["BLOB_NAME"],
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection instance to azure blob storage stablished Successfully.
>>> File saved to your 'local' file system with name 'azure_container_data_driver_data_2022_04_20_16_49_29.csv' Successfully.

BigQuery Connector - Get Dataโ€‹

Initializing the BigQueryConnector with the credentials in json file.

from katonic.connectors.python.bigquery import BigQueryConnector
CREDS = "big-query-credentials.json"
query = """
SELECT Churn, AccountWeeks, ContractRenewal, DataPlan
FROM `big-query-connect-364013.001.big-query-connect-364013`
LIMIT 50
"""

df = BigQueryConnector(
bigquery_credential_path=CREDS,
query=query,
file_name="driver_data",
)
df.get_data()
>>> Connection to bigquery stablished Successfully.
>>> File saved to your 'local' file system with name 'biquery_driver_data_2022_11_30_11_39_08.csv' Successfully.

DuckDB Connector - Get Dataโ€‹

Initializing the DuckDBConnector with the provided configuration.

from katonic.connectors.python.duckdb import DuckDBConnector
df = DuckDBConnector(
database="sparkdb.duckdb",
query="SELECT * FROM driver_stats_data",
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to duckdb stablished Successfully.
>>> File saved to your 'local' file system with name 'duckdb_sparkdb_driver_data_2022_11_30_11_54_13.csv' Successfully.

MySQL Connector - Get Dataโ€‹

mysql-credentials.json

{
"HOST": "localhost",
"PORT": 3306,
"DB_NAME": "dbname",
"USER": "localhost",
"PASSWORD": "password",
"TABLE_NAME": "driver_data"
}
# Define all your configurations inside a JSON file.
import json

with open('mysql-credentials.json') as f:
config = json.load(f)

Initializing the MySQLConnector with the provided credentials and configuration.

from katonic.connectors.python.mysql import MySQLConnector
df = MySQLConnector(
host=config["HOST"],
port=config["PORT"],
db_name=config["DB_NAME"],
user=config["USER"],
password=config["PASSWORD"],
table_name=config["TABLE_NAME"],
query="SELECT * FROM driver_stats_data",
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to mysql stablished Successfully.
>>> File saved to your 'local' file system with name 'mysql_dbname_driver_data_2022_04_20_14_23_19.csv' Successfully.

PostgreSQL Connector - Get Dataโ€‹

postgresql-credentials.json

{
"HOST": "localhost",
"PORT": 5432,
"DB_NAME": "dbname",
"USER": "postgres",
"PASSWORD": "postgres",
"TABLE_NAME": "driver_data",
"DB_SCHEMA": "public"
}
# Define all your configurations inside a JSON file.
import json

with open('postgresql-credentials.json') as f:
config = json.load(f)

Initializing the PostgreSQLConnector with the provided credentials and configuration.

from katonic.connectors.python.postgres import PostgreSQLConnector
df = PostgreSQLConnector(
host=config["HOST"],
port=config["PORT"],
db_name=config["DB_NAME"],
user=config["USER"],
password=config["PASSWORD"],
db_schema=config["DB_SCHEMA"],
table_name=config["TABLE_NAME"],
query="SELECT * FROM driver_stats_data",
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to postgres stablished Successfully.
>>> File saved to your 'local' file system with name 'postgres_public_dbname_driver_data_2022_04_20_12_09_25.csv' Successfully.

Redshift Connector - Get Dataโ€‹

redshift-credentials.json

{
"HOST": "localhost",
"PORT": 3306,
"DB_NAME": "dbname",
"USER": "localhost",
"PASSWORD": "password",
"TABLE_NAME": "driver_data"
}
# Define all your configurations inside a JSON file.
import json

with open('redshift-credentials.json') as f:
config = json.load(f)

Initializing the RedshiftConnector with the provided credentials and configuration.

from katonic.connectors.python.redshift import RedshiftConnector
df = RedshiftConnector(
host=config["HOST"],
database=config["DB_NAME"],
user=config["USER"],
password=config["PASSWORD"],
table_name=config["TABLE_NAME"],
query="SELECT * FROM driver_stats_data",
port=config["PORT"],
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to Amazon redshift stablished Successfully.
>>> File saved to your 'local' file system with name 'redshift_sparkdb_driver_data_2022_04_20_06_51_49.csv' Successfully.

AWS S3 Connector - Get Dataโ€‹

aws-s3-credentials.json

{
"AWS_ACCESS_KEY": "AWS_ACCESS_KEY",
"AWS_SECRET_KEY": "AWS_SECRET_KEY",
"AWS_SESSION_TOKEN": "AWS_SESSION_TOKEN",
"REGION_NAME": "REGION_NAME",
"PROFILE_NAME": "PROFILE_NAME",
"BUCKET_NAME": "BUCKET_NAME",
"OBJECT_NAME": "OBJECT_NAME"
}
# Define all your configurations inside a JSON file.
import json

with open('aws-s3-credentials.json') as f:
config = json.load(f)

Initializing the AWSS3Connector with the provided credentials and configuration.

from katonic.connectors.python.s3 import AWSS3Connector
df = AWSS3Connector(
aws_access_key=config["AWS_ACCESS_KEY"],
aws_secret_key=config["AWS_SECRET_KEY"],
aws_session_token=config["AWS_SESSION_TOKEN"],
region_name=config["REGION_NAME"],
profile_name=config["PROFILE_NAME"],
bucket_name=config["BUCKET_NAME"],
object_name=config["OBJECT_NAME"],
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection instance to aws s3 stablished Successfully.
>>> File saved to your 'local' file system with name 's3_driver_data_2022_04_20_06_51_49.csv' Successfully.

SAP HANA Connector - Get Dataโ€‹

sap-hana-credentials.json

{
"HOST": "localhost",
"PORT": 3306,
"USER": "localhost",
"PASSWORD": "password",
"TABLE_NAME": "driver_data",
"SCHEMA": "SCHEMA"
# Define all your configurations inside a JSON file.
import json

with open('sap-hana-credentials.json') as f:
config = json.load(f)

Initializing the SAPHANAConnector with the provided credentials and configuration.

from katonic.connectors.python.sap_hana import SAPHANAConnector
df = SAPHANAConnector(
host=config["HOST"],
port=config["PORT"],
user=config["USER"],
password=config["PASSWORD"],
table_name=config["TABLE_NAME"],
schema=config["SCHEMA"],
query="SELECT * FROM driver_stats_data",
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to SAP HANA stablished Successfully.
>>> File saved to your 'local' file system with name 'sap_hana_TPCH_SH1_driver_data_2022_04_20_06_51_49.csv' Successfully.

SnowFlake Connector - Get Dataโ€‹

snowflake-credentials.json

{
"USER": "username",
"PASSWORD": "password",
"ACCOUNT": "id.uae-north.azure",
"DATABASE": "SNOWFLAKE_SAMPLE_DATA",
"TABLE_NAME": "CUSTOMER",
"SCHEMA": "TPCH_SF1",
"WAREHOUSE": "COMPUTE_WH"
}
# Define all your configurations inside a JSON file.
import json

with open('snowflake-credentials.json') as f:
config = json.load(f)

Initializing the SnowFlakeConnector with the provided credentials and configuration.

from katonic.connectors.python.snowflake import SnowFlakeConnector

df = SnowFlakeConnector(
user=config["USER"],
password=config["PASSWORD"],
account=config["ACCOUNT"],
database=config["DATABASE"],
table_name=config["TABLE_NAME"],
schema=config["SCHEMA"],
warehouse=config["WAREHOUSE"],
query="SELECT * FROM TPCH_SF1.CUSTOMER",
output="local",
file_name="driver_data",
)
df.get_data()
>>> Connection to snowflake stablished Successfully.
>>> File saved to your 'local' file system with name 'snowflake_TPCH_SF1_SNOWFLAKE_SAMPLE_DATA_driver_data_2022_04_20_08_46_38.csv' Successfully.