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

- Scroll down to see “download a free specialised edition”.

- Click Download now below the Express section.
- Once the executable is downloaded, go to the folder in which it is downloaded.
- Double-click exe.

- Once ready, the below screen shall be shown.

- Keep the option as Custom. Click it to move to the next screen.

- Specify the location in which the SQL Server should be downloaded.
- Press Install. The process is initiated.

- Once the download process is done, it shall be shown.

- The installation process is initiated by Wizard.

- Go with the first option. The license terms shall be shown.

- Tick the box – I accept terms and conditions. Press Next.

- Do not do anything. The next processing starts after this.

- Press Show Details. The view is expanded.

- Once completed, the below screen shall be shown.

- Press Next. The setup file installation starts.

- Once done, the screen is shown as below.

- Press Next.

- Tick the first check box – Database Engine Servers.

- Press Next. The Instance Configuration screen shall be shown.

- Give the instance a name and press Next.

- Press Next on the Server Configuration page.

- Choose the Mixed Mode option under the Authentication Mode section.

- Set the password in the password boxes that appeared on the above screen.

- Press Next. The process started.

- Once the process completes, it asks for restarting the computer.

- OK to restart.
SSMS Setup
- Go the Microsoft Web page to download SSMS.

- Once downloaded, run the executable.

- Press Install. The progress bar screen shall be shown.

- On success, the screen is shown.

- Close to shut the screen.
- To verify the successful installation, start MSSQL server from the Windows menu.

- Under that, SQL Server Management menu is available. Click that.

- The console opens up as below.

- Type the instance name you gave in the Server name field.
- Click Connect. Success.

Also read:
- How to install MySQL in Linux for Python
- How to install Python on Chromebook
- How to install Kali Linux on Mac
- How t install MySQL on Mac for Python
- How to install MySQL on Windows for Python
- Best Linux Distros for gaming
- How to replace Chrome OS with Linux
- Debian vs Ubuntu
- How to install Python IDLE in Linux
Installation of pyodbc
- Make sure python is available in the system.
- Open the command prompt.
- The below command shall be executed.
c:\user\> pip install pyodbc
- The installation shall begin and finish as below.

- Enter the command “python” as below.
C:/users> python
- The version shall be displayed.

- The next command is to be executed by pressing ENTER as below.
import pyodbc
- All good.

- Execute the below –
cnx = pyodbc.connect(‘Driver ={SQL Server};’‘Server=localhost;’ ‘Database=test;’ ‘Trusted_Connection=yes;’)
- Success as shown below.

- Next, type the command and execute as below.
cursor = cnx.cursor()
- Then, execute the below command.
cursor.execute (‘SELECT FNAME from EMPLOYEE_MASTER’)
- Now, type the following to print the row as a result of Above SQL statement.
for row in cursor: print(row)
- You shall see the records displayed in the command window.
- The connectivity between SQL Server db and Python is established successfully.
Takeaway
Following the steps correctly makes the developer life easy in setting up the multi-tier application environment and easily interact with different components easily.