CTRL + K
Integrations
Microsoft SQL Server

Microsoft SQL Server

The SQL Server integration synchronizes metadata from your SQL Server databases into the data lineage graph.

Web App

SQL Server Integration

Fields

FieldValueExample
NameName for connectionMicrosoft SQL Server
NamespaceNamespace for the connection, see namespacesdefault
hostDatabase hostsample-database.cudyk77thtpt.us-west-2.rds.amazonaws.com
portDatabase port5432
databaseDatabase namejaffle_shop
userDatabase user
passwordDatabase password
â„šī¸

Your database will need to be accessible from wherever you are running the Grai server. If you are using Grai Cloud your database will need to be accessible from the internet.

Python Library

Installation

You'll need to first install the ODBC drivers for SQL Server before installing the SQL Server integration.

â„šī¸

If you're on a mac these can be installed with brew install unixodbc. If you're using Apple Silicon and encounter any issues running or installing the drivers we have some additional support documentation here (opens in a new tab)

pip install grai-source-mssql

This installs the Grai SQL Server integration, which is now ready to run in python.

Connecting & Syncing

The integration comes equipped with the client library already but we will need a python terminal or Jupyter Notebook to execute a few commands to establish a connection and begin querying the server.

Spin up your favorite python terminal then:

import os
from grai_source_mssql.base import update_server

For now we will use the default user credentials though you are free to create a new user / api keys from the server admin interface at http://localhost:8000/admin (opens in a new tab).

client = ClientV1("localhost", "8000", username="null@grai.io", password="super_secret")

Now we can update the server with data from any mssql source. In order to do so you will need to pass credentials and namespace into the update_server function. Namespace is used to uniquely identify the nodes and when used consistently will allow you to add to the node from any source.

Using example variables, in order to update the server with your metadata, simply run:

update_server(client, host=[your_mssql_host], user=[your_mssql_user], password=[your_mssql_password], namespace=[your_grai_namespace])
â„šī¸

There are other option parameters like database, protocol, and port which are also available. More detail about ODBC connection string arguments are available from Microsoft (opens in a new tab)