问题
I am getting, self.cnxn = pyodbc.connect(self.connStr) pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') while connecting to sql-server database.I am reading the server information,username,password of the database from the .ini file.But i am not able to connect to the db.Can anyone help me to resolve this?(Refer the Below Code)
def connectDB(self):
config = configparser.ConfigParser()
config.read('databaseconnect.ini')
DBconnect='DatabaseConnection'
self.server = config[DBconnect]['server']
self.database = config[DBconnect]['database']
self.username = config[DBconnect]['username']
self.password = config[DBconnect]['password']
self.connStr = config[DBconnect]['connStr']
self.cnxn = pyodbc.connect(self.connStr)
self.cursor = self.cnxn.cursor()
来源:https://stackoverflow.com/questions/57175589/pyodbc-operationalerror-hyt00-uhyt00-unixodbcmicrosoftodbc-driver-1