def run_test_064(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) create = 'CREATE SCHEMA AUTHORIZATION t' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t1( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t2( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t3( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t4( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, 't') else: result = ifx_db.tables(conn, None, 'T') for i in range(0, ifx_db.num_fields(result)): print "%s, " % ifx_db.field_name(result, i) print print i = 0 row = ifx_db.fetch_tuple(result) while (row): ifx_db.num_fields(result) if (i < 4): print ", " + row[1] + ", " + row[2] + ", " + row[3] + ", , \n" i = i + 1 row = ifx_db.fetch_tuple(result) ifx_db.free_result(result) ifx_db.exec_immediate(conn, 'DROP TABLE t.t1') ifx_db.exec_immediate(conn, 'DROP TABLE t.t2') ifx_db.exec_immediate(conn, 'DROP TABLE t.t3') ifx_db.exec_immediate(conn, 'DROP TABLE t.t4')
def run_test_060(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info( conn ) create = 'CREATE SCHEMA AUTHORIZATION t' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t1( c1 INTEGER, c2 VARCHAR(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t2( c1 INTEGER, c2 VARCHAR(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t3( c1 INTEGER, c2 VARCHAR(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t4( c1 INTEGER, c2 VARCHAR(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass if conn: if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, 't') else: result = ifx_db.tables(conn, None, 'T') i = 0 row = ifx_db.fetch_both(result) while ( row ): if (i < 4): print "/%s/%s" % (row[1], row[2]) i = i + 1 row = ifx_db.fetch_both(result) ifx_db.exec_immediate(conn, 'DROP TABLE t.t1') ifx_db.exec_immediate(conn, 'DROP TABLE t.t2') ifx_db.exec_immediate(conn, 'DROP TABLE t.t3') ifx_db.exec_immediate(conn, 'DROP TABLE t.t4') print "done!" else: print "no connection: #{ifx_db.conn_errormsg}";
def run_test_063(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) result = ifx_db.tables(conn, None, "SYSIBM", "", "VIEW") if (type(result) == ifx_db.IBM_DBStatement): print "Resource is a DB2 Statement" ifx_db.free_result(result)
def run_test_062(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) create = 'CREATE SCHEMA AUTHORIZATION t' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t1( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t2( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t3( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t4( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass if conn: if (server.DBMS_NAME[0:3] == 'IDS'): schema = 't' else: schema = 'T' result = ifx_db.tables(conn, None, schema) i = 0 row = ifx_db.fetch_both(result) while (row): str = row[1] + "/" + row[2] + "/" + row[3] if (i < 4): print str i = i + 1 row = ifx_db.fetch_both(result) ifx_db.exec_immediate(conn, 'DROP TABLE t.t1') ifx_db.exec_immediate(conn, 'DROP TABLE t.t2') ifx_db.exec_immediate(conn, 'DROP TABLE t.t3') ifx_db.exec_immediate(conn, 'DROP TABLE t.t4') print "done!" else: print "no connection: #{ifx_db.conn_errormsg}"
def run_test_061(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info( conn ) create = 'CREATE SCHEMA AUTHORIZATION t' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t1( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t2( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t3( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t4( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass if conn: server = ifx_db.server_info( conn ) op = {ifx_db.ATTR_CASE: ifx_db.CASE_UPPER} ifx_db.set_option(conn, op, 1) result = ifx_db.tables(conn, None, 't'); i = 0 row = ifx_db.fetch_both(result) while ( row ): str = row['TABLE_SCHEM'] + row['TABLE_NAME'] + row['TABLE_TYPE'] if (i < 4): print str i = i + 1 row = ifx_db.fetch_both(result) ifx_db.exec_immediate(conn, 'DROP TABLE t.t1') ifx_db.exec_immediate(conn, 'DROP TABLE t.t2') ifx_db.exec_immediate(conn, 'DROP TABLE t.t3') ifx_db.exec_immediate(conn, 'DROP TABLE t.t4') print "done!" else: print "no connection: %s" % ifx_db.conn_errormsg()
def run_test_065(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) create = 'CREATE SCHEMA AUTHORIZATION t' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t1( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t2( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t3( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass create = 'CREATE TABLE t.t4( c1 integer, c2 varchar(40))' try: result = ifx_db.exec_immediate(conn, create) except: pass result = ifx_db.tables(conn, None, '%', "t3") columns = ifx_db.num_fields(result) for i in range(0, columns): print "%s, " % ifx_db.field_name(result, i) print "\n\n" row = ifx_db.fetch_tuple(result) while (row): final = ", " + row[1] + ", " + row[2] + ", " + row[3] + ", , " row = ifx_db.fetch_tuple(result) print final ifx_db.free_result(result) ifx_db.exec_immediate(conn, 'DROP TABLE t.t1') ifx_db.exec_immediate(conn, 'DROP TABLE t.t2') ifx_db.exec_immediate(conn, 'DROP TABLE t.t3') ifx_db.exec_immediate(conn, 'DROP TABLE t.t4')
def run_test_066(self): conn = ifx_db.connect(config.ConnStr, config.user, config.password) server = ifx_db.server_info(conn) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'animals') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIMALS') # NOTE: This is a workaround # function fetch_object() to be implemented... # row = ifx_db.fetch_object(result) class Row: pass data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'animal_pics') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIMAL_PICS') # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) if (server.DBMS_NAME[0:3] == 'IDS'): result = ifx_db.tables(conn, None, config.user.lower(), 'anime_cat') else: result = ifx_db.tables(conn, None, config.user.upper(), 'ANIME_CAT') # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) while (data): row = Row() if (server.DBMS_NAME[0:3] == 'IDS'): row.table_schem = data['table_schem'] row.table_name = data['table_name'] row.table_type = data['table_type'] row.remarks = data['remarks'] print "Schema: %s" % row.table_schem print "Name: %s" % row.table_name print "Type: %s" % row.table_type print "Remarks: %s\n" % row.remarks else: row.TABLE_SCHEM = data['TABLE_SCHEM'] row.TABLE_NAME = data['TABLE_NAME'] row.TABLE_TYPE = data['TABLE_TYPE'] row.REMARKS = data['REMARKS'] print "Schema: %s" % row.TABLE_SCHEM print "Name: %s" % row.TABLE_NAME print "Type: %s" % row.TABLE_TYPE print "Remarks: %s\n" % row.REMARKS # row = ifx_db.fetch_object(result) data = ifx_db.fetch_assoc(result) ifx_db.free_result(result) ifx_db.close(conn)