No project description provided
Project description
ODBC 2 Deltalake
This is a package that supports reading from ODBC and writing to a scd2 DeltaTable. The delta table will always have the following "system" cols:
- __timestamp : The Date of the Load
- __is_deleted : True for a deletion of a record
- __is_full_load : True if it was a full load, meaning an implicit deletion of not delivered records
Currently, this package is focused very much on Microsoft SQL Server. But it should not be too hard to add support for other DB Systems.
This packages handles delta's based on MS-SQL's "timestamp"/"rowversion" DataType or based on Temporal Tables. Other methods will be added later on. It does detect updates to records that happened differently, eg if a restore happened in the source.
Usage
First, pip install it:
pip install odbc2deltalake[local,local_azure]
It's as simple as this:
from odbc2deltalake import write_db_to_delta
await write_db_to_delta(
your_odbc_connection_string,
(your_db_schema, your_table_name),
Path("YOUR_TARGET_PATH")
)
Usage with Databricks
You can also use databricks instead of the default delta-rs/duckdb implementation.
In that case you can do pip install odbc2deltalake
without any dependencies other than Databricks Spark/DBUtils
from odbc2deltalake.destination.databricks import DatabricksDestination
from odbc2deltalake.reader.spark_reader import SparkReader
from odbc2deltalake import write_db_to_delta
dest = DatabricksDestination(dbutils=dbutils,container="raw", account="some_account", path="raw/super_path", schema="abfss")
reader = SparkReader(spark=spark, sql_config={ # see https://docs.databricks.com/en/connect/external-systems/sql-server.html
"host": "some_host",
"port": "1433",
"user": "some_user",
"encrypt": "true",
"password": "what_ever",
"database": "mypage"
}, spark_format="sqlserver")
await write_db_to_delta(reader, ("dbo", "user"), dest)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for odbc2deltalake-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a328c2974b8b6de06dfe472fad0f0b3e94aff60438ac979b84a19ac585d8cdd5 |
|
MD5 | 980fe357fc0057b8f7646b482a1ac98f |
|
BLAKE2b-256 | 96e62d1d7f5f865deff5a5488c5aabb49ed6e792f60f89f5ea3fd7370aae57aa |