|
| 1 | +--- |
| 2 | +sidebar_position: 4 |
| 3 | +--- |
| 4 | + |
| 5 | +# SQL Server |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +## OS Dependencies |
| 10 | + |
| 11 | +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. |
| 12 | + |
| 13 | +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)**. |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +To use this adapter, you must install the necessary dependencies as an extra: |
| 18 | + |
| 19 | +```bash |
| 20 | +pip install "intugle[sqlserver]" |
| 21 | +``` |
| 22 | + |
| 23 | +## Profile Configuration |
| 24 | + |
| 25 | +To configure the connection, add a `sqlserver` entry to your `profiles.yml` file. |
| 26 | + |
| 27 | +**`profiles.yml`** |
| 28 | +```yaml |
| 29 | +sqlserver: |
| 30 | + name: my_sqlserver_source # A unique name for this source |
| 31 | + type: sqlserver |
| 32 | + host: "your_server_address" |
| 33 | + port: 1433 |
| 34 | + user: "your_username" |
| 35 | + password: "your_password" |
| 36 | + database: "your_database_name" |
| 37 | + schema: "dbo" # Optional, defaults to 'dbo' |
| 38 | + encrypt: true # Optional, defaults to true |
| 39 | +``` |
| 40 | +
|
| 41 | +| Key | Description | Required | Default | |
| 42 | +| ---------- | ------------------------------------------------------------------------------------------------------- | -------- | ------- | |
| 43 | +| `name` | A unique identifier for this data source connection. | Yes | | |
| 44 | +| `type` | The type of the adapter. Must be `sqlserver`. | Yes | | |
| 45 | +| `host` | The hostname or IP address of your SQL Server instance. | Yes | | |
| 46 | +| `port` | The port number for the connection. | No | `1433` | |
| 47 | +| `user` | The username for authentication. | Yes | | |
| 48 | +| `password` | The password for authentication. | Yes | | |
| 49 | +| `database` | The name of the database to connect to. | Yes | | |
| 50 | +| `schema` | The default schema to use for tables that are not fully qualified. | No | `dbo` | |
| 51 | +| `encrypt` | Whether to encrypt the connection. Recommended to keep this `true`. | No | `true` | |
| 52 | + |
| 53 | +## Dataset Configuration |
| 54 | + |
| 55 | +When defining datasets for the `SemanticModel`, use the `type: "sqlserver"` and provide the table name as the `identifier`. |
| 56 | + |
| 57 | +```python |
| 58 | +from intugle import SemanticModel |
| 59 | +
|
| 60 | +datasets = { |
| 61 | + "customers": { |
| 62 | + "type": "sqlserver", |
| 63 | + "identifier": "Customers" # The name of the table in SQL Server |
| 64 | + }, |
| 65 | + "orders": { |
| 66 | + "type": "sqlserver", |
| 67 | + "identifier": "Orders" |
| 68 | + }, |
| 69 | + # ... other datasets |
| 70 | +} |
| 71 | +
|
| 72 | +# Build the semantic model |
| 73 | +sm = SemanticModel(datasets, domain="E-commerce") |
| 74 | +sm.build() |
| 75 | +``` |
0 commit comments