2017-01-24 4 views
0

ホストを接続することができません:pythonanywhere.completion Pythonの2.7 + pyodbcPyodbc:

私はSQLのリモートサーバーに接続するようにしてみてください。 アドレスとポートが正しい。私はそれらを "..."で置き換えました。

戻りエラー:接続できません:Adaptive Serverが使用できないか、存在しません。 エラーがコードです。助けてください

[odbc.log 


[ODBC][17658][1485155828.109606][__handles.c][450] 
    Exit:[SQL_SUCCESS] 
    Environment = 0x1a21380 
[ODBC][17658][1485155828.120011][SQLSetEnvAttr.c][182] 
    Entry:    
    Environment = 0x1a21380    
    Attribute = SQL_ATTR_ODBC_VERSION    
    Value = 0x3    
    StrLen = 4 
[ODBC][17658][1485155828.122501][SQLSetEnvAttr.c][349] 
    Exit:[SQL_SUCCESS] 
[ODBC][17658][1485155828.125084][SQLAllocHandle.c][364] 
    Entry: 
    Handle Type = 2 
    Input Handle = 0x1a21380 
[ODBC][17658][1485155828.127630][SQLAllocHandle.c][482] 
    Exit:[SQL_SUCCESS] 
    Output Handle = 0x1a17890 
[ODBC][17658][1485155828.130371][SQLDriverConnectW.c][286] 
    Entry:    
    Connection = 0x1a17890    
    Window Hdl = (nil)    
    Str In = [UID=sa;DATABASE=...;TDS_Version=8.0;DRIVER=FreeTDS;PWD=.....;SERVER=.....;ClientCharset=UTF8;PORT=...;][length = 114]    
    Str Out = (nil)    
    Str Out Max = 0    
    Str Out Ptr = (nil)    
    Completion = 0 
    UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' 

[ODBC][17658][1485155829.140224][SQLDriverConnectW.c][777] 
    Exit:[SQL_ERROR] 
[ODBC][17658][1485155829.143848][SQLDriverConnect.c][687] 
    Entry:    
    Connection = 0x1a17890    
    Window Hdl = (nil)    
    Str In = [UID=sa;DATABASE=...;TDS_Version=8.0;DRIVER=FreeTDS;PWD=**********;SERVER=......;ClientCharset=UTF8;PORT=....;][length = 114 (SQL_NTS)]    
    Str Out = 0x7ffc3876ab00    
    Str Out Max = 2048    
    Str Out Ptr = (nil)    
    Completion = 0 
    UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' 

    DIAG [08S01] [FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist 

    DIAG [08001] [FreeTDS][SQL Server]Unable to connect to data source 

[ODBC][17658][1485155830.154707][SQLDriverConnect.c][1273] 
    Exit:[SQL_ERROR] 
[ODBC][17658][1485155830.157808][SQLGetDiagRec.c][661] 
    Entry:     
    Connection = 0x1a17890     
    Rec Number = 1     
    SQLState = 0x7ffc3876b6e0     
    Native = 0x7ffc3876b6cc     
    Message Text = 0x7ffc3876b6f0     
    Buffer Length = 1023     
    Text Len Ptr = 0x7ffc3876b6ca 
[ODBC][17658][1485155830.160870][SQLGetDiagRec.c][698] 
    Exit:[SQL_SUCCESS]      
    SQLState = 08S01      
    Native = 0x7ffc3876b6cc -> 20009      
    Message Text = [[unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist] 
[ODBC][17658][1485155830.163884][SQLFreeHandle.c][279] 
    Entry: 
    Handle Type = 2 
    Input Handle = 0x1a17890 
[ODBC][17658][1485155830.173285][SQLFreeHandle.c][330] 
    Exit:[SQL_SUCCESS] 




odbcinst.ini 

[ODBC] 
Trace= Yes 
TraceFile = /home/gamesale/odbc.log 

[FreeTDS] 
Description = TDS driver (Sybase/MS SQL) 
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so 
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so 
UsageCount = 1 

freetds.conf 
[global] 
tds version = 8.0 
host = .... 
port = ... 
text size = 64512 
try server login = yes 
try domain login = no 
client charset = UTF-8 

odbc.ini 

[srv-db4] 
Description=srv-db4 
Driver=FreeTDS 
Servername=srv-db4 


test.py 

odbc.iniimport os 
import pyodbc 

os.environ["ODBCSYSINI"] = "/home/gamesale" 


try: 
    cnx = pyodbc.connect(
    DRIVER = 'FreeTDS', 
    TDS_Version = '8.0', 
    ClientCharset = 'UTF8', 
    PORT = '...', 
    SERVER = '....', 
    DATABASE = '..', 
    UID = '..', 
    PWD = '.....' 
) 
    cursor = cnx.cursor() 
    print ("SUCCESS") 
except Exception as e: 
    print ("Error: " + str(e)) 

答えて

1

あなたは無料アカウントをお持ちですか?無料のアカウントは、httpを使用してPythonAnywhereの外部に接続するだけで、サイトの特定のホワイトリストに接続できます。 herehere

関連する問題