def client_print(db): client = ibm_db.client_info(db) print "DRIVER_NAME: string(%d) \"%s\"" % (len(client.DRIVER_NAME), client.DRIVER_NAME) print "DRIVER_VER: string(%d) \"%s\"" % (len(client.DRIVER_VER), client.DRIVER_VER) print "DATA_SOURCE_NAME: string(%d) \"%s\"" % (len(client.DATA_SOURCE_NAME), client.DATA_SOURCE_NAME) print "DRIVER_ODBC_VER: string(%d) \"%s\"" % (len(client.DRIVER_ODBC_VER), client.DRIVER_ODBC_VER) print "ODBC_VER: string(%d) \"%s\"" % (len(client.ODBC_VER), client.ODBC_VER) print "ODBC_SQL_CONFORMANCE: string(%d) \"%s\"" % (len(client.ODBC_SQL_CONFORMANCE), client.ODBC_SQL_CONFORMANCE) print "APPL_CODEPAGE: int(%s)" % client.APPL_CODEPAGE print "CONN_CODEPAGE: int(%s)" % client.CONN_CODEPAGE
def conectaDB2(): try: conn = ibm_db.pconnect( "DATABASE=" + database + "; HOSTNAME=" + hostname + "; PORT=" + port + "; PROTOCOL=" + protocol + "; UID=" + userid + "; PWD=" + password + ";", '', '') except: print('Connection fault with DATABASE!\nError Code: {0}'.format( ibm_db.conn_error())) sys.exit() info = ibm_db.client_info(conn) print( 'CONNECTED! DATA_SOURCE_NAME: {0} CONN_CODEPAGE: {3} DRIVER_NAME: {1} DRIVER_ODBC_VER: {2} ODBC_VER: {4}' .format(info.DATA_SOURCE_NAME, info.DRIVER_NAME, info.DRIVER_ODBC_VER, info.CONN_CODEPAGE, info.ODBC_VER)) return conn
def run_test_310(self): conn = ibm_db.connect(config.database, config.user, config.password) client = ibm_db.client_info(conn) if client: print("DRIVER_NAME: string(%d) \"%s\"" % (len(client.DRIVER_NAME), client.DRIVER_NAME)) print("DRIVER_VER: string(%d) \"%s\"" % (len(client.DRIVER_VER), client.DRIVER_VER)) print("DATA_SOURCE_NAME: string(%d) \"%s\"" % (len(client.DATA_SOURCE_NAME), client.DATA_SOURCE_NAME)) print("DRIVER_ODBC_VER: string(%d) \"%s\"" % (len(client.DRIVER_ODBC_VER), client.DRIVER_ODBC_VER)) print("ODBC_VER: string(%d) \"%s\"" % (len(client.ODBC_VER), client.ODBC_VER)) print("ODBC_SQL_CONFORMANCE: string(%d) \"%s\"" % (len(client.ODBC_SQL_CONFORMANCE), client.ODBC_SQL_CONFORMANCE)) print("APPL_CODEPAGE: int(%s)" % client.APPL_CODEPAGE) print("CONN_CODEPAGE: int(%s)" % client.CONN_CODEPAGE) ibm_db.close(conn) else: print("Error.")
def run_test_310(self): conn = ibm_db.connect(config.database, config.user, config.password) client = ibm_db.client_info(conn) if client: print "DRIVER_NAME: string(%d) \"%s\"" % (len(client.DRIVER_NAME), client.DRIVER_NAME) print "DRIVER_VER: string(%d) \"%s\"" % (len(client.DRIVER_VER), client.DRIVER_VER) print "DATA_SOURCE_NAME: string(%d) \"%s\"" % (len(client.DATA_SOURCE_NAME), client.DATA_SOURCE_NAME) print "DRIVER_ODBC_VER: string(%d) \"%s\"" % (len(client.DRIVER_ODBC_VER), client.DRIVER_ODBC_VER) print "ODBC_VER: string(%d) \"%s\"" % (len(client.ODBC_VER), client.ODBC_VER) print "ODBC_SQL_CONFORMANCE: string(%d) \"%s\"" % (len(client.ODBC_SQL_CONFORMANCE), client.ODBC_SQL_CONFORMANCE) print "APPL_CODEPAGE: int(%s)" % client.APPL_CODEPAGE print "CONN_CODEPAGE: int(%s)" % client.CONN_CODEPAGE ibm_db.close(conn) else: print "Error."
conn = ibm_db.connect(dsn, "", "") print("Connected to database: ", dsn_database, "as user: "******"on host: ", dsn_hostname) except: print("Unable to connect: ", ibm_db.conn_errormsg()) #%% server = ibm_db.server_info(conn) print("DBMS_NAME: ", server.DBMS_NAME) print("DBMS_VER: ", server.DBMS_VER) print("DB_NAME: ", server.DB_NAME) #%% client = ibm_db.client_info(conn) print("DRIVER_NAME: ", client.DRIVER_NAME) print("DRIVER_VER: ", client.DRIVER_VER) print("DATA_SOURCE_NAME: ", client.DATA_SOURCE_NAME) print("DRIVER_ODBC_VER: ", client.DRIVER_ODBC_VER) print("ODBC_VER: ", client.ODBC_VER) print("ODBC_SQL_CONFORMANCE: ", client.ODBC_SQL_CONFORMANCE) print("APPL_CODEPAGE: ", client.APPL_CODEPAGE) print("CONN_CODEPAGE: ", client.CONN_CODEPAGE) #%% ibm_db.close(conn) #%%
svrConnection = None clientInfo = False # Create An Instance Of The Db2ConnectionMgr Class And Use It To Connect To A Db2 Server conn = Db2ConnectionMgr('SERVER', dbName, '', '', userID, passWord) conn.openConnection() if conn.returnCode is True: svrConnection = conn.connectionID else: conn.closeConnection() exit(-1) # Attempt To Obtain Information About The Db2 Client Being Used print("Obtaining information about the Db2 client ... ", end="") try: clientInfo = ibm_db.client_info(svrConnection) except Exception: pass # If Information About The Client Could Not Be Obtained, Display An Error Message if clientInfo is False: print("\nERROR: Unable to obtain Db2 client information.\n") # Otherwise, Complete The Status Message; Then Format And Display The Data Retrieved else: print("Done!\n") # Display A Report Header print("Client details:") print( "____________________________________________________________________")