No project description provided
Project description
dagster-mssql-bcp
ODBC is slow 🐢 bcp is fast! 🐰
This is a custom dagster IO manager for loading data into SQL Server using the bcp
utility.
What you need to run it
Pypi
pip install dagster-mssql-bcp
BCP Utility
The bcp
utility must be installed on the machine that is running the dagster pipeline.
See Microsoft's documentation for more information.
Ideally you should place this on your PATH
, but you can specify in the IO configuration where it is located.
ODBC Drivers
You need the ODBC drivers installed on the machine that is running the dagster pipeline.
See Microsoft's documentation for more information.
Permissions
The user running the dagster pipeline must have the necessary permissions to load data into the SQL Server database.
CREATE SCHEMA
CREATE/ALTER TABLES
Basic Usage
Polars
Polars processes as a LazyFrame
. Either a DataFrame
or LazyFrame
can be provided as an output of your asset before its cast automatically to lazy
from dagster import asset, Definitions
from dagster_mssql_bcp import PolarsBCPIOManager
import polars as pl
io_manager = PolarsBCPIOManager(
host="my_mssql_server",
database="my_database",
user="username",
password="password",
query_props={
"TrustServerCertificate": "yes",
},
bcp_arguments={"-u": ""},
bcp_path="/opt/mssql-tools18/bin/bcp",
)
@asset(
metadata={
"asset_schema": [
{"name": "id", "type": "INT"},
],
"schema": "my_schema",
}
)
def my_polars_asset(context):
return pl.DataFrame({"id": [1, 2, 3]})
@asset(
metadata={
"asset_schema": [
{"name": "id", "type": "INT"},
],
"schema": "my_schema",
}
)
def my_polars_asset_lazy(context):
return pl.LazyFrame({"id": [1, 2, 3]})
defs = Definitions(
assets=[my_polars_asset, my_polars_asset_lazy],
io_managers={
"io_manager": io_manager,
},
)
Pandas
from dagster import asset, Definitions
from dagster_mssql_bcp import PandasBCPIOManager
import pandas as pd
io_manager = PandasBCPIOManager(
host="my_mssql_server",
database="my_database",
user="username",
password="password",
query_props={
"TrustServerCertificate": "yes",
},
bcp_arguments={"-u": ""},
bcp_path="/opt/mssql-tools18/bin/bcp",
)
@asset(
metadata={
"asset_schema": [
{"name": "id", "type": "INT"},
],
"schema": "my_schema",
}
)
def my_pandas_asset(context):
return pd.DataFrame({"id": [1, 2, 3]})
defs = Definitions(
assets=[my_pandas_asset],
io_managers={
"io_manager": io_manager,
},
)
The asset schema
defines your table structure and your asset returns your data to load.
Docs
For more details see assets doc, io manager doc, and for how its implemented, the dev doc.
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
File details
Details for the file dagster_mssql_bcp-0.0.11.tar.gz
.
File metadata
- Download URL: dagster_mssql_bcp-0.0.11.tar.gz
- Upload date:
- Size: 40.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49785f72a756f7bd91c261664a0091bb12a5a9356d2c196da86506673017e768 |
|
MD5 | 1c6d74255d01582fd0b210f9707ddaef |
|
BLAKE2b-256 | 4eac49b2d267a874cf3f83a56f5bcc6e7d914aaace13fa12a00f77234963af9d |
Provenance
The following attestation bundles were made for dagster_mssql_bcp-0.0.11.tar.gz
:
Publisher:
python-publish.yml
on cody-scott/dagster-mssql-bcp
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
dagster_mssql_bcp-0.0.11.tar.gz
- Subject digest:
49785f72a756f7bd91c261664a0091bb12a5a9356d2c196da86506673017e768
- Sigstore transparency entry: 148709374
- Sigstore integration time:
- Predicate type:
File details
Details for the file dagster_mssql_bcp-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: dagster_mssql_bcp-0.0.11-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab187ddffef9363035dc387f2106ec8256c67e26fef849dd12c9d6a8b79bfcb |
|
MD5 | c52d817d664ea82b0080f9aee14b3181 |
|
BLAKE2b-256 | 5e78c87ab64f6e81bd001a4596b7f8017056601948568d538eba38a48583573c |
Provenance
The following attestation bundles were made for dagster_mssql_bcp-0.0.11-py3-none-any.whl
:
Publisher:
python-publish.yml
on cody-scott/dagster-mssql-bcp
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
dagster_mssql_bcp-0.0.11-py3-none-any.whl
- Subject digest:
6ab187ddffef9363035dc387f2106ec8256c67e26fef849dd12c9d6a8b79bfcb
- Sigstore transparency entry: 148709377
- Sigstore integration time:
- Predicate type: