pymssqlを使用して以下のようにcodeを書きましたがerrorとともに上手く行きませんでした。ご教示願えればと思います。(usernameとpasswordは*として記述しています。)
python
1import pymssql 2dsn = 'HIMSSPROD06E' 3database = 'reference' 4username = '****' 5password = '****' 6cnxn = pymssql.connect('HIMSSPROD06E\HIMSSPROD06E',username,password,database) 7cursor = cnxn.cursor() 8 9cursor.excute('SELECT @@version;') 10row = cursor.fetchone() 11while row: 12 print("%s" % (row[0])) 13 row = cursor.fetchone() 14 15cnxn.close() 16print('connection closed')
↓その結果のerror内容
error
1Traceback (most recent call last): 2 File "src\pymssql.pyx", line 636, in pymssql.connect 3 File "src\_mssql.pyx", line 1957, in _mssql.connect 4 File "src\_mssql.pyx", line 676, in _mssql.MSSQLConnection.__init__ 5 File "src\_mssql.pyx", line 1683, in _mssql.maybe_raise_MSSQLDatabaseException 6 7_mssql.MSSQLDatabaseException: (18456, b"Login failed for user '****'.DB-Lib 8 error message 20018, severity 14:\nGeneral SQL Server error: Check messages fro 9m the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server conne 10ction failed (HIMSSPROD06E\HIMSSPROD06E)\n") 11 12During handling of the above exception, another exception occurred: 13 14Traceback (most recent call last): 15 File "C:\Python-zero\education2.py", line 6, in <module> 16 cnxn = pymssql.connect('HIMSSPROD06E\HIMSSPROD06E',username,password,databas 17e) 18 File "src\pymssql.pyx", line 642, in pymssql.connect 19pymssql.OperationalError: (18456, b"Login failed for user '****'.DB-Lib erro 20r message 20018, severity 14:\nGeneral SQL Server error: Check messages from the 21 SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection 22 failed (HIMSSPROD06E\HIMSSPROD06E)\n")
よろしく御願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/30 13:07 編集