pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

家住魔仙堡 提交于 2019-12-24 08:17:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!