我正在获取,pyodbc.OperationalError :('HYT00',u'[HYT00] [unixODBC] [Microsoft] [SQL Server的ODBC驱动程序17]登录超时已过期(0)(SQLDriverConnect)'),同时连接到sql服务器数据库。我正在从.ini文件中读取服务器信息,用户名,密码。但是我无法连接到数据库。有人可以帮助我解决此问题吗(请参阅下面的代码)>
databaseconnect.ini
[DatabaseConnection]
server=192.167.169.107
database=intdb
username=user3
password=laset$
connStr=DRIVER=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1;SERVER='+self.server+';DATABASE='+self.database+';'+ 'UID='+self.username+';PWD='+ self.password+';Port=1433
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()