Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsite/docs/connectors/implementing-a-connector.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
---

# Implementing a Connector
Expand Down
75 changes: 75 additions & 0 deletions docsite/docs/connectors/sqlserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
sidebar_position: 4
---

# SQL Server

The SQL Server adapter allows `intugle` to connect to Microsoft SQL Server and Azure SQL databases. It uses the modern [`mssql-python`](https://github.com/microsoft/mssql-python) driver, which connects directly to SQL Server without needing an external driver manager like ODBC.

## OS Dependencies

The `mssql-python` driver may require additional system-level libraries depending on your operating system (e.g., `libltdl` on Linux). Before proceeding, please ensure you have installed any necessary prerequisites for your OS.

For detailed, OS-specific installation instructions, please refer to the official **[Microsoft mssql-python documentation](httpshttps://learn.microsoft.com/en-us/sql/connect/python/mssql-python/python-sql-driver-mssql-python-quickstart?view=sql-server-ver17&tabs=windows%2Cazure-sql)**.

## Installation

To use this adapter, you must install the necessary dependencies as an extra:

```bash
pip install "intugle[sqlserver]"
```

## Profile Configuration

To configure the connection, add a `sqlserver` entry to your `profiles.yml` file.

**`profiles.yml`**
```yaml
sqlserver:
name: my_sqlserver_source # A unique name for this source
type: sqlserver
host: "your_server_address"
port: 1433
user: "your_username"
password: "your_password"
database: "your_database_name"
schema: "dbo" # Optional, defaults to 'dbo'
encrypt: true # Optional, defaults to true
```

| Key | Description | Required | Default |
| ---------- | ------------------------------------------------------------------------------------------------------- | -------- | ------- |
| `name` | A unique identifier for this data source connection. | Yes | |
| `type` | The type of the adapter. Must be `sqlserver`. | Yes | |
| `host` | The hostname or IP address of your SQL Server instance. | Yes | |
| `port` | The port number for the connection. | No | `1433` |
| `user` | The username for authentication. | Yes | |
| `password` | The password for authentication. | Yes | |
| `database` | The name of the database to connect to. | Yes | |
| `schema` | The default schema to use for tables that are not fully qualified. | No | `dbo` |
| `encrypt` | Whether to encrypt the connection. Recommended to keep this `true`. | No | `true` |

## Dataset Configuration

When defining datasets for the `SemanticModel`, use the `type: "sqlserver"` and provide the table name as the `identifier`.

```python
from intugle import SemanticModel

datasets = {
"customers": {
"type": "sqlserver",
"identifier": "Customers" # The name of the table in SQL Server
},
"orders": {
"type": "sqlserver",
"identifier": "Orders"
},
# ... other datasets
}

# Build the semantic model
sm = SemanticModel(datasets, domain="E-commerce")
sm.build()
```
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ postgres = [
"asyncpg>=0.30.0",
"sqlglot>=27.20.0",
]
sqlserver = [
"mssql-python>=0.13.1",
"sqlglot>=27.20.0",
]


[project.urls]
Expand All @@ -92,6 +96,7 @@ dev = [
"asyncpg>=0.30.0",
"databricks-sql-connector>=4.1.3",
"ipykernel>=6.30.1",
"mssql-python>=0.13.1",
"pysonar>=1.2.0.2419",
"pyspark>=4.0.1",
"pytest>=8.4.1",
Expand Down
1 change: 1 addition & 0 deletions src/intugle/adapters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def import_module(name: str) -> ModuleInterface:
"intugle.adapters.types.snowflake.snowflake",
"intugle.adapters.types.databricks.databricks",
"intugle.adapters.types.postgres.postgres",
"intugle.adapters.types.sqlserver.sqlserver",
]


Expand Down
3 changes: 2 additions & 1 deletion src/intugle/adapters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def get_dataset_data_type() -> type:
from intugle.adapters.types.duckdb.models import DuckdbConfig
from intugle.adapters.types.postgres.models import PostgresConfig
from intugle.adapters.types.snowflake.models import SnowflakeConfig
from intugle.adapters.types.sqlserver.models import SQLServerConfig

DataSetData = pd.DataFrame | DuckdbConfig | SnowflakeConfig | DatabricksConfig | PostgresConfig
DataSetData = pd.DataFrame | DuckdbConfig | SnowflakeConfig | DatabricksConfig | PostgresConfig | SQLServerConfig
else:
# At runtime, this is dynamically determined
DataSetData = Any
Expand Down
Empty file.
18 changes: 18 additions & 0 deletions src/intugle/adapters/types/sqlserver/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Literal, Optional

from intugle.common.schema import SchemaBase


class SQLServerConnectionConfig(SchemaBase):
user: str
password: str
host: str
port: int = 1433
database: str
schema: str = "dbo"
encrypt: bool = True


class SQLServerConfig(SchemaBase):
identifier: str
type: Literal["sqlserver"] = "sqlserver"
Loading