This article covers:

  1. How to set up a connection to a SQL Server database
  2. How to add datasets
  3. How to do connection overrides on a SQL Server connection
  4. The supported SQL Server data types and the respective Luzmo data type they are mapped to

1. How to setup a SQL Server connection

To make a connection to SQL Server, navigate to the Connections page, select New Connection, then SQL Server from the New Connection modal:

You will be prompted to provide the following connection details to establish a connection to your SQL Server database:

  • Host: Specify the database host
  • Port: Specify the port number
  • Database: Enter the name of your SQL Server database.
  • Username: Provide the username associated with your SQL Server database.
  • Password: Enter the password corresponding to the SQL Server user.

Notes:

  1. By default we will always make connections to SQL Server with the property ApplicationIntent=ReadOnly, ensuring that read-only replicas are being used if possible to run the queries! 
  2. To ensure secure access to your SQL Server database, it is recommended to whitelist Luzmo's range of IP addresses. You should whitelist Luzmo's range of IP addresses as described here.

2. How to add datasets

Once you have connected your SQL Server you can add datasets as explained here.

  1. You can select one or multiple datasets as available in your SQL Server and link them in Luzmo to ensure they can be used together in a dashboard.
  2. You can also add SQL datasets by switching to the SQL tab in the dataset creation modal. While creating or editing a SQL dataset, you can parameterize anything within the query by specifying {{metadata.< parameter name >|< default value >}}. Find out more about parameterized SQL Datasets.

Note: you can connect your datasets with topography data (geometry/geography types) via our connector.

Also make sure to check out this article on Preparing your data for analytics.

To find out how to add datasets using our API, please refer to the examples in our developer documentation.

3. SQL Server Connection Overrides

When generating an Authorization token to grant a user acces to your embedded dashboards it is possible to override the data source properties in the authorization request to dynamically use different properties. Find out more about connection overrides.

The fields available for overriding a SQL Server connection are as follows:

  • Connection ID: The ID of the Connection to be overridden. Retrieve the ID to specify as detailed here.
  • host: The new database host to connect to. The database must be of the same type as the originally configured database.
  • port:The new port to connect to.
  • user: The new user to use when connecting.
  • password: The new password to use when connecting.
  • database:The new database to retrieve data from.
  • schema:The new schema to retrieve data from.
  • table:The new table to retrieve data from.
  • datasets: List of dataset-level overrides. Useful if you want to override only a single dataset in your dashboard or if you have a separate table per client. The SQL query of the dataset can also be overridden if it's a SQL dataset within Luzmo.
    • schema: the new schema to connect to
    • table: The new SQL Server table to query.
    • sql: The new SQL query to run (only for SQL datasets). Alternatively, you could also use parameterized SQL Datasets.

Our developer documentation has more info about connection overrides and examples of SQL Server connection overrides.

Example code demonstrating how to override a SQL Server connection:

import Luzmo from '@luzmo/nodejs-sdk';
const client = new Luzmo({
  api_key: '<your Luzmo API key>',
  api_token: '<your Luzmo API token>',
  host: 'https://api.luzmo.com:443'
});


const response = await client.create('authorization',
  {
    type: "embed",
    username: "< A unique and immutable identifier for your user >",
    name: "< user name >",
    email: "< user email >",
    suborganization: "< a suborganization name >",
    access: {
      collections: [
        
        {
          id: "<collection_id>",
          inheritRights: "use"
        }
      ]
    },
    account_overrides: {
      <your connection_id>: {
        host: "<The new database host URL to connect to>",
        user: "<username>",
        password: "<password>"
      }
    }
  }
);

4. Supported Data Types

Data Type in SQL Server Data Type in Luzmo
bigint numeric
binary hierarchy
bit hierarchy
char hierarchy
nchar hierarchy
date datetime
datetime datetime
datetime2 datetime
datetimeoffset datetime
decimal numeric
float numeric
int numeric
money numeric
ntext hierarchy
numeric numeric
nvarchar hierarchy
real numeric
rowversion numeric
smalldatetime datetime
smallint numeric
smallmoney numeric
text hierarchy
time datetime
timestamp datetime
tinyint numeric
uniqueidentifier hierarchy
varbinary hierarchy
varchar hierarchy
xml hierarchy
hierarchyid hierarchy

Need more information?

Do you still have questions? Let us know how we can help.
Send us feedback!