Skip to content

Commit b3d8e98

Browse files
committed
✨ feat: update installation instructions for optional mssql-python and pyodbc backends
1 parent d4dc214 commit b3d8e98

2 files changed

Lines changed: 59 additions & 82 deletions

File tree

CONTRIBUTING.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ The functional tests require a running SQL Server instance. You can easily spin
3232
make server
3333
```
3434

35-
The default development flow uses the existing ODBC-based path. If you want to develop or test the optional `mssql-python` backend instead, make sure the package is installed in your environment before running tests.
35+
The default development flow uses the ODBC-based path, but the ODBC driver itself is now an optional dependency. If you want to develop or test that backend, install either the adapter extra or the driver itself before running tests.
3636

3737
```shell
38-
pip install mssql-python
38+
pip install -U "dbt-sqlserver[pyodbc]"
39+
# or
40+
pip install -U pyodbc
41+
```
42+
43+
If you want to develop or test the optional `mssql-python` backend instead, install either the adapter extra or the driver itself before running tests.
44+
45+
```shell
46+
pip install -U "dbt-sqlserver[mssql]"
47+
# or
48+
pip install -U mssql-python
3949
```
4050

4151
On Debian/Ubuntu-based environments, `mssql-python` may also require these system libraries:
@@ -77,7 +87,7 @@ make unit
7787
make functional
7888
```
7989

80-
This remains the documented test procedure for both connection backends. When the `mssql-python` flag is enabled, run the same commands after installing `mssql-python` and setting `SQLSERVER_TEST_USE_MSSQL_PYTHON=True` in `test.env`.
90+
This remains the documented test procedure for both connection backends. When the `pyodbc` path is enabled, run the same commands after installing `dbt-sqlserver[pyodbc]` or `pyodbc`. When the `mssql-python` flag is enabled, run the same commands after installing `dbt-sqlserver[mssql]` or `mssql-python` and setting `SQLSERVER_TEST_USE_MSSQL_PYTHON=True` in `test.env`.
8191

8292
## CI/CD
8393

README.md

Lines changed: 46 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -9,90 +9,56 @@ E.g. version 1.1.x of the adapter will be compatible with dbt-core 1.1.x.
99

1010
We've bundled all documentation on the dbt docs site:
1111

12-
* [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
13-
* [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
12+
- [Profile setup & authentication](https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile)
13+
- [Adapter documentation, usage and important notes](https://docs.getdbt.com/reference/resource-configs/mssql-configs)
1414

1515
Join us on the [dbt Slack](https://getdbt.slack.com/archives/CMRMDDQ9W) to ask questions, get help, or to discuss the project.
1616

1717
## Installation
1818

19-
By default this adapter uses the Microsoft ODBC driver.
19+
The base package does not bundle any connection driver. Install the adapter together with the backend extra that matches your setup.
2020

21-
This adapter requires the Microsoft ODBC driver to be installed:
21+
Latest version: ![PyPI](https://img.shields.io/pypi/v/dbt-sqlserver?label=latest%20stable&logo=pypi)
22+
Latest pre-release: ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/dbt-msft/dbt-sqlserver?include_prereleases&label=latest%20pre-release&logo=pypi)
23+
24+
### `pyodbc` backend
25+
26+
The legacy and currently default ODBC path uses `pyodbc` and the Microsoft ODBC driver.
27+
28+
```shell
29+
pip install -U "dbt-sqlserver[pyodbc]"
30+
```
31+
32+
You also need the Microsoft ODBC driver for SQL Server installed on your system:
2233
[Windows](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows) |
2334
[macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver16) |
2435
[Linux](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-sql-server?view=sql-server-ver16)
2536

2637
<details><summary>Debian/Ubuntu</summary>
27-
<p>
2838

29-
Make sure to install the ODBC headers as well as the driver linked above:
39+
Install the ODBC headers as well as the driver linked above:
3040

3141
```shell
3242
sudo apt-get install -y unixodbc-dev
3343
```
3444

35-
</p>
3645
</details>
3746

38-
Latest version: ![PyPI](https://img.shields.io/pypi/v/dbt-sqlserver?label=latest%20stable&logo=pypi)
39-
40-
```shell
41-
pip install -U dbt-sqlserver
42-
```
47+
### `mssql-python` backend
4348

44-
Latest pre-release: ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/dbt-msft/dbt-sqlserver?include_prereleases&label=latest%20pre-release&logo=pypi)
49+
An alternative backend that does not require the ODBC driver.
4550

4651
```shell
47-
pip install -U --pre dbt-sqlserver
52+
pip install -U "dbt-sqlserver[mssql]"
4853
```
4954

50-
### Optional: `mssql-python` backend
51-
52-
This adapter can also use the `mssql-python` driver behind a feature flag.
53-
54-
Install it explicitly when you want to use that backend:
55+
On Debian/Ubuntu-based systems, `mssql-python` requires these system libraries:
5556

5657
```shell
57-
pip install -U mssql-python
58+
sudo apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
5859
```
5960

60-
When this backend is enabled, the adapter does not require the ODBC driver-based connection path for that profile.
61-
62-
## Changelog
63-
64-
See [the changelog](CHANGELOG.md)
65-
66-
## Configuration
67-
68-
### Flags
69-
70-
- `dbt_sqlserver_use_default_schema_concat`: *(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
71-
72-
- `use_mssql_python`: *(default: `false` in the profile)* Switches the connection backend from the legacy ODBC / `pyodbc` path to the `mssql-python` driver for that target profile.
73-
74-
| Flag value | `custom_schema_name` | Result |
75-
|---|---|---|
76-
| `false` (default, legacy) | *(none)* | `target.schema` |
77-
| `false` (default, legacy) | `"reporting"` | `reporting` |
78-
| `true` (dbt-core standard) | *(none)* | `target.schema` |
79-
| `true` (dbt-core standard) | `"reporting"` | `target.schema_reporting` |
80-
81-
When `false` (the default), the adapter uses its legacy behaviour: `custom_schema_name` is used **as-is** without being prefixed by `target.schema`.
82-
When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`, which concatenates `target.schema` + `_` + `custom_schema_name`.
83-
84-
**Example usage in `dbt_project.yml`:**
85-
86-
```yaml
87-
vars:
88-
dbt_sqlserver_use_default_schema_concat: true # Enable standard schema concatenation
89-
```
90-
91-
> **Note:** If you want to permanently customise schema generation and avoid any future deprecation of this flag, override the `sqlserver__generate_schema_name` macro directly in your project.
92-
93-
### `mssql-python` feature flag usage
94-
95-
Enable the backend per target in your `profiles.yml`:
61+
Enable it per target in your `profiles.yml`:
9662

9763
```yaml
9864
your_profile:
@@ -108,39 +74,40 @@ your_profile:
10874
password: your-password
10975
encrypt: true
11076
trust_cert: false
111-
use_mssql_python: true
77+
use_mssql_python: true # <-- enables this backend
11278
```
11379
114-
#### Notes
80+
## Changelog
11581
116-
- `use_mssql_python: true` is a profile-level feature flag.
117-
- When enabled, the adapter uses `mssql-python` instead of the legacy `pyodbc` connection path.
118-
- The legacy ODBC driver setting is only needed for profiles that continue to use the ODBC backend.
119-
- If you enable `use_mssql_python`, make sure the `mssql-python` package is installed in the environment running dbt.
120-
- On Debian/Ubuntu-based environments, `mssql-python` also requires `libltdl7`, `libkrb5-3`, and `libgssapi-krb5-2`.
121-
- This path is intended to fail fast when required dependencies or unsupported settings are missing.
82+
See [the changelog](CHANGELOG.md)
12283
123-
#### Testing
84+
## Configuration
12485
125-
For local development and validation, use the documented adapter workflow from `CONTRIBUTING.md`:
86+
### `use_mssql_python`
12687

127-
```shell
128-
make dev
129-
make server
130-
cp test.env.sample test.env
131-
make unit
132-
make functional
133-
```
88+
*(default: `false`)* Set to `true` in a profile target to use the `mssql-python` backend instead of `pyodbc`. The adapter fails if the required driver is not installed.
13489

135-
To exercise the `mssql-python` backend in tests, configure the profile or environment so that the target under test sets:
90+
### `dbt_sqlserver_use_default_schema_concat`
13691

137-
```yaml
138-
use_mssql_python: true
139-
```
92+
*(default: `false`)* Controls schema name generation when a [custom schema](https://docs.getdbt.com/docs/build/custom-schemas) is set on a model.
93+
94+
| Value | `custom_schema_name` | Result |
95+
|---|---|---|
96+
| `false` (default) | *(none)* | `target.schema` |
97+
| `false` (default) | `"reporting"` | `reporting` |
98+
| `true` | *(none)* | `target.schema` |
99+
| `true` | `"reporting"` | `target.schema_reporting` |
140100

141-
If you are testing in the devcontainer, the backend prerequisites are installed automatically. Outside the devcontainer, install `mssql-python` and the system libraries above before running the unit or functional suite.
101+
When `false`, `custom_schema_name` is used as-is without being prefixed by `target.schema`.
102+
When `true`, the adapter delegates to dbt-core's `default__generate_schema_name`.
142103

104+
```yaml
105+
# dbt_project.yml
106+
vars:
107+
dbt_sqlserver_use_default_schema_concat: true
108+
```
143109

110+
> **Note:** To permanently customise schema generation without a flag dependency, override the `sqlserver__generate_schema_name` macro directly in your project.
144111

145112
## Contributing
146113

@@ -149,7 +116,7 @@ If you are testing in the devcontainer, the backend prerequisites are installed
149116
[![Integration tests on Azure](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-azure.yml/badge.svg)](https://github.com/dbt-msft/dbt-sqlserver/actions/workflows/integration-tests-azure.yml)
150117

151118
This adapter is community-maintained.
152-
You are welcome to contribute by creating issues, opening or reviewing pull requests or helping other users in Slack channel.
119+
You are welcome to contribute by creating issues, opening or reviewing pull requests, or helping other users in the Slack channel.
153120
If you're unsure how to get started, check out our [contributing guide](CONTRIBUTING.md).
154121

155122
## License

0 commit comments

Comments
 (0)