Unable to download SQL database from server

I´ve been asked to download some data using pyodbc however I´m having some problems, here is the code:

import pyodbc
import pandas as pd
    
conn = pyodbc.connect("Driver={SQL Server};"
                      "Server=database.net;"
                      "Database=Spectrometry;"
                      "uid=user;pwd=password")
    
Users = pd.read_sql("SELECT * FROM Users", conn)
Activity = pd.read_sql("SELECT * FROM Activity", conn)

After executing this I get:

InterfaceError: (‘IM002’, ‘[IM002] [Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)’)

Answer

I feel you may have made a tiny mistake will writing the code. Looking at the documentation and and example available.

I belieleve that it should be :

import pyodbc
import pandas as pd
    
conn = pyodbc.connect("Driver=SQL Server;"  #  <= No {} needed
                      "Server=database.net;"
                      "Database=Spectrometry;"
                      "uid=user;pwd=password")
    
Users = pd.read_sql("SELECT * FROM Users", conn)
Activity = pd.read_sql("SELECT * FROM Activity", conn)

Another thing I might add is, have you checked the available odbc drivers available on your set up ? I suggest you run:

import pyodbc
pyodbc.drivers()

It should give you a list of available drivers name (The name you need to specify on the connect method). If the list is empty you might want to look into how to install odbc driver on your environment. For sql server version 15 they are available here.