Can't connect to SQL database using Python: I believe it's an issue with my Driver

I’m attempting to edit a SQL table but I cannot get connected to the database, this is my connection string:

conn = pyodbc.connect(‘Driver={ODBC Driver 17 for SQL Server};’
‘Server=servername;’
‘Database=database_name;’
‘Trusted_Connection=yes;’
‘uid=username; pwd=password’)

I know for a fact that my database name, server name, and credentials are correct. I keep getting the error message:
{
pyodbc.OperationalError: (‘08001’, '[08001] [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. (53) (SQLDriverConnect); [08001] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0); [08001] [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible.
}

I have also tried the other drivers that I found in my System32 folder being ‘SQL Server,’ ‘SQL Server Native Client 11.0,’ and ‘ODBC Driver 18 for SQL Server.’

I’ve been working at this for hours, each driver gives a slightly different message that the SQL server either cannot be found or accessed. Is there something wrong with my code? I also tried connecting with MySQL but I do not believe it is supported with the authentication I need for this database.
Any help is much appreciated!