So I want to make my program to not connect to a microsoft database and if the connection takes longer then 3 seconds then to show an error then quit the program, also all using pyodbc.
def SpecialFunc(server:str,port:str,username:str,password:str,db_name:str):
try:
pyodbc.SQL_CONVERT_TIME = 1
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER={'+server+'};PORT={'+port+'};DATABASE={'+db_name+'};UID={'+username+'};PWD={'+password+'};')
except Exception as e:
print(e)
This CODE DOESN'T WORK and I can't figure out so may someone help me?