How to install MSSQL for Python on Windows

SQL Server (Microsoft) is being used by organizations to manage their enterprise level applications built on the .Net framework.

Python comes into play while building applications for complex algorithms in a simple manner with high performance.

The scenario is to make a connection between MS SQL and Python application on Windows environment. 

MS SQL Express Installation on Windows

  1. Go to 
open too download MSSQL
  1. Scroll down to see “download a free specialised edition”.
Download MSSQL developer or Express
  1. Click Download now below the Express section.
  2. Once the executable is downloaded, go to the folder in which it is downloaded. 
  3. Double-click exe. 
Double click on setup file
  1. Once ready, the below screen shall be shown.
select custom setup option
  1. Keep the option as Custom. Click it to move to the next screen.
keep the custom setup option to install
  1. Specify the location in which the SQL Server should be downloaded.
  2. Press Install. The process is initiated.
initiate the MSSQL installation
  1. Once the download process is done, it shall be shown.
press done once complete
  1.  The installation process is initiated by Wizard.
continue with installation wizard
  1. Go with the first option. The license terms shall be shown.
check first option and accept license
  1. Tick the box – I accept terms and conditions. Press Next.
Accept the license and click next
  1. Do not do anything. The next processing starts after this.
complete the process
  1. Press Show Details. The view is expanded.
expand the details to see detailed installation
  1. Once completed, the below screen shall be shown.
select next to continue the setup
  1. Press Next. The setup file installation starts.
continue to finish isntallation
  1. Once done, the screen is shown as below.
click done to finish
  1. Press Next. 
go to next screen to select modules
  1. Tick the first check box – Database Engine Servers.
setup database engine server
  1. Press Next. The Instance Configuration screen shall be shown.
configure the instance
  1. Give the instance a name and press Next.
name the instance and press next
  1. Press Next on the Server Configuration page.
configure the server and press next
  1. Choose the Mixed Mode option under the Authentication Mode section.
select Mixed Mode option under the Authentication Mode section.
  1. Set the password in the password boxes that appeared on the above screen.
set the password for MSSQL server database
  1. Press Next. The process started.
select next to proceed with process
  1. Once the process completes, it asks for restarting the computer.
restart the system to finish installation
  1. OK to restart. 

SSMS Setup

  1. Go the Microsoft Web page to download SSMS.
open Microsoft page to download SQL server management studio
  1. Once downloaded, run the executable.
run the installation
  1. Press Install. The progress bar screen shall be shown.
press install and wait to finish
  1. On success, the screen is shown.
close the window once installation done
  1. Close to shut the screen. 
  2. To verify the successful installation, start MSSQL server from the Windows menu.
verify the successful installation
  1. Under that, SQL Server Management menu is available. Click that.
go to menu and search for SQL server management
  1. The console opens up as below.
Open SQL management and enter user password
  1. Type the instance name you gave in the Server name field.
  2. Click Connect. Success.
connect to the database server

Also read:

Installation of pyodbc

  1. Make sure python is available in the system.
  2. Open the command prompt.
  3. The below command shall be executed.
c:\user\> pip install pyodbc
  1. The installation shall begin and finish as below.
open console and install PyODBC
  1. Enter the command “python” as below.
C:/users> python
  1. The version shall be displayed.
import pyodbc in your code
  1. The next command is to be executed by pressing ENTER as below.
import pyodbc
  1. All good. 
run import to check if PyODBC is install
  1. Execute the below –
cnx = pyodbc.connect(‘Driver ={SQL Server};’‘Server=localhost;’ ‘Database=test;’ ‘Trusted_Connection=yes;’)
  1. Success as shown below.
shows connections with database
  1.  Next, type the command and execute as below.
cursor = cnx.cursor()
  1. Then, execute  the below command.
cursor.execute (‘SELECT FNAME from EMPLOYEE_MASTER’)
  1. Now, type the following to print the row as a result of Above SQL statement.
for row in cursor: print(row)
  1. You shall see the records displayed in the command window.
  2. The connectivity between SQL Server db and Python is established successfully.


Following the steps correctly makes the developer life easy in setting up the multi-tier application environment and easily interact with different components easily.

Scroll to Top