Microsoft SQL Server
Install dlt with MS SQLโ
To install the DLT library with MS SQL dependencies, use:
pip install dlt[mssql]
Setup guideโ
Prerequisitesโ
The Microsoft ODBC Driver for SQL Server must be installed to use this destination.
This cannot be included with dlt
's python dependencies, so you must install it separately on your system. You can find the official installation instructions here.
Supported driver versions:
ODBC Driver 18 for SQL Server
ODBC Driver 17 for SQL Server
You can also configure the driver name explicitly.
Create a pipelineโ
1. Initialize a project with a pipeline that loads to MS SQL by running:
dlt init chess mssql
2. Install the necessary dependencies for MS SQL by running:
pip install -r requirements.txt
or run:
pip install dlt[mssql]
This will install dlt
with the mssql
extra, which contains all the dependencies required by the SQL server client.
3. Enter your credentials into .dlt/secrets.toml
.
For example, replace with your database connection info:
[destination.mssql.credentials]
database = "dlt_data"
username = "loader"
password = "<password>"
host = "loader.database.windows.net"
port = 1433
connect_timeout = 15
You can also pass a SQLAlchemy-like database connection:
# keep it at the top of your toml file! before any section starts
destination.mssql.credentials="mssql://loader:<password>@loader.database.windows.net/dlt_data?connect_timeout=15"
To connect to an mssql
server using Windows authentication, include trusted_connection=yes
in the connection string. This method is useful when SQL logins aren't available, and you use Windows credentials.
destination.mssql.credentials="mssql://username:password@loader.database.windows.net/dlt_data?trusted_connection=yes"
The username and password must be filled out with the appropriate login credentials or left untouched. Leaving these empty is not recommended.
To pass credentials directly, you can use the credentials
argument passed to dlt.pipeline
or pipeline.run
methods.
pipeline = dlt.pipeline(pipeline_name='chess', destination='postgres', dataset_name='chess_data', credentials="mssql://loader:<password>@loader.database.windows.net/dlt_data?connect_timeout=15")
Write dispositionโ
All write dispositions are supported.
If you set the replace
strategy to staging-optimized
, the destination tables will be dropped and
recreated with an ALTER SCHEMA ... TRANSFER
. The operation is atomic: mssql supports DDL transactions.
Data loadingโ
Data is loaded via INSERT statements by default. MSSQL has a limit of 1000 rows per INSERT, and this is what we use.
Supported file formatsโ
- insert-values is used by default
Supported column hintsโ
mssql will create unique indexes for all columns with unique
hints. This behavior may be disabled.
Syncing of dlt
stateโ
This destination fully supports dlt state sync.
Data typesโ
MS SQL does not support JSON columns, so JSON objects are stored as strings in nvarchar
columns.
Additional destination optionsโ
The mssql destination does not create UNIQUE indexes by default on columns with the unique
hint (i.e., _dlt_id
). To enable this behavior:
[destination.mssql]
create_indexes=true
You can explicitly set the ODBC driver name:
[destination.mssql.credentials]
driver="ODBC Driver 18 for SQL Server"
When using a SQLAlchemy connection string, replace spaces with +
:
# keep it at the top of your toml file! before any section starts
destination.mssql.credentials="mssql://loader:<password>@loader.database.windows.net/dlt_data?driver=ODBC+Driver+18+for+SQL+Server"
dbt supportโ
No dbt support yet.
Additional Setup guidesโ
- Load data from Shopify to Microsoft SQL Server in python with dlt
- Load data from Stripe to Microsoft SQL Server in python with dlt
- Load data from Google Analytics to Microsoft SQL Server in python with dlt
- Load data from Google Sheets to Microsoft SQL Server in python with dlt
- Load data from AWS S3 to Microsoft SQL Server in python with dlt
- Load data from Chess.com to Microsoft SQL Server in python with dlt
- Load data from Pipedrive to Microsoft SQL Server in python with dlt
- Load data from Jira to Microsoft SQL Server in python with dlt
- Load data from GitHub to Microsoft SQL Server in python with dlt
- Load data from Zendesk to Microsoft SQL Server in python with dlt
- Load data from Salesforce to Microsoft SQL Server in python with dlt
- Load data from Notion to Microsoft SQL Server in python with dlt
- Load data from HubSpot to Microsoft SQL Server in python with dlt
- Load data from Airtable to Microsoft SQL Server in python with dlt
- Load data from Mux to Microsoft SQL Server in python with dlt
- Load data from Slack to Microsoft SQL Server in python with dlt
- Load data from MongoDB to Microsoft SQL Server in python with dlt