domino logo
4.2
  • Overview
  • Domino Cloud
  • Get started
  • Work with data
  • Develop models
  • Scale out distributed computing
  • Deploy models
  • Publish Apps
  • Projects
  • Collaborate
  • Workspaces
  • Jobs
  • Environments
  • Executions
  • Launchers
  • Environment variables
  • Secure credential store
  • Organizations
  • Domino CLI
  • Troubleshooting
  • Get help
  • Additional resources
domino logo
About Domino
Domino Data LabKnowledge BaseData Science BlogTraining
>

Connect to MSSQL

This topic describes how to connect to a Microsoft SQL Server (MSSQL) from Domino. You must have network connectivity between Impala and your Domino deployment.

Warning
Connect to MSSQL
  1. To interact with MSSQL databases from Python, Domino recommends the pymssql package.

  2. Use the following Dockerfile instruction to install pymssql in your environment.

    This instruction assumes you already have pip installed.

RUN pip install pymssql

+ . You must set up the following Domino environment variables to store secure information about your MSSQL connection. * DB_SERVER * DB_USERNAME * DB_PASSWORD

+ See Secure Credential Storage to learn more about Domino environment variables.

+ See the pymssql documentation for detailed information about how to use the package. The following is an example of connecting to MSSQL with Python where the following is true:

  • You have set up environment variables noted previously.

  • The server hosts a database named myData with a table named addresses.

    from os import getenv
    import pymssql
    
    server = getenv("DB_SERVER")
    user = getenv("DB_USERNAME")
    password = getenv("DB_PASSWORD")
    
    conn = pymssql.connect(server, user, password, "myData")
    cursor = conn.cursor()
    
    cursor.execute('SELECT * FROM addresses')
    row = cursor.fetchone()
    while row:
        print("ID=%d, Name=%s" % (row[0], row[1]))
        row = cursor.fetchone()
    
    conn.close()
Connect R and RODBC to MSSQL
  1. To interact with MSSQL databases from R, Domino recommends the RODBC library. You can use an alternative package if you’d like.

  2. Use the following Dockerfile instructions to add the MSSQL drivers to your Ubuntu 16.04 environment.

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17
  1. See Microsoft’s documentation for the Dockerfile instructions to add the MSSQL drivers to your Domino-supported Ubuntu environment.

  2. See the RStudio RODBC documentation for information about how to use the package.

Next steps

  • After connecting to your Data Source, learn how to Use Data Sources.

  • Share this Data Source with your collaborators.

Domino Data Lab
Knowledge Base
Data Science Blog
Training
Copyright © 2023 Domino Data Lab. All rights reserved.