How to Connect Pyodbc to SQL Server Using Python

Handful concept to run SQL queries from jupyter notebook

Amit Chauhan
The Pythoneers

--

A photo by the Author

This article will be very helpful to run the SQL server queries using python. Here we will see two types of connections to connect the jupyter notebook and MS SQL server using python.

Pyodbc

It is used to connect the databases with ODBC, the odbc is an API in the computer system that stands for open database connectivity to access databases in the system. There is some ODBC-compliant database and Microsoft SQL Server is one of the databases.

SQL-Server

SQL Server is an RDBMS type i.e. Relational Database Management System for storing and fetching data in table formats. It is a very useful tool for business intelligence for analytics, data science, and machine learning applications.

Types of connection options

1. DSN Type 
2. Driver Type

Tools and library requirements:

  • Python ( Anaconda distribution is better)
  • MS SQL Server
  • Pyodbc library for python

The link to download the anaconda is here. The link to download the MS SQL Server is here.

--

--