Exemplo n.º 1
0
    def run_test_240(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        result = ifx_db.exec_immediate(conn, "select * from sales")
        result2 = ifx_db.exec_immediate(conn, "select * from staff")
        result3 = ifx_db.exec_immediate(conn, "select * from emp_photo")

        for i in range(0, ifx_db.num_fields(result)):
            print str(i) + ":" + str(ifx_db.field_width(result, i))

        print "\n-----"

        for i in range(0, ifx_db.num_fields(result2)):
            print str(i) + ":" + str(
                ifx_db.field_width(result2, ifx_db.field_name(result2, i)))

        print "\n-----"

        for i in range(0, 3):
            print str(i) + ":" + str(ifx_db.field_width(
                result3, i)) + "," + str(ifx_db.field_display_size(result3, i))

        print "\n-----"
        print "region:%s" % ifx_db.field_type(result, 'region')

        print "5:%s" % ifx_db.field_type(result2, 5)
Exemplo n.º 2
0
    def run_test_180(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)
        if conn:
            result = ''
            result2 = ''
            try:
                result = ifx_db.exec_immediate(
                    conn,
                    "insert int0 t_string values(123,1.222333,'one to one')")
            except:
                pass
            if result:
                cols = ifx_db.num_fields(result)
                print "col:", cols, ", "
                rows = ifx_db.num_rows(result)
                print "affected row:", rows
            else:
                print ifx_db.stmt_errormsg()
            try:
                result = ifx_db.exec_immediate(
                    conn, "delete from t_string where a=123")
            except:
                pass
            if result:
                cols = ifx_db.num_fields(result)
                print "col:", cols, ", "
                rows = ifx_db.num_rows(result)
                print "affected row:", rows
            else:
                print ifx_db.stmt_errormsg()

        else:
            print "no connection"
Exemplo n.º 3
0
    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')
Exemplo n.º 4
0
 def run_test_241(self):
   conn = ifx_db.connect(config.ConnStr, config.user, config.password)
   
   result = ifx_db.exec_immediate(conn, "select * from sales")
   result2 = ifx_db.exec_immediate(conn, "select * from staff")
   result3 = ifx_db.exec_immediate(conn, "select * from emp_photo")
   
   for i in range(0, ifx_db.num_fields(result)):
     print str(ifx_db.field_width(result,i))
   
   print "\n-----"
   
   for i in range(0, ifx_db.num_fields(result2)):
     print str(ifx_db.field_width(result2,ifx_db.field_name(result2,i)))
Exemplo n.º 5
0
    def run_test_124(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            result = ifx_db.exec_immediate(
                conn,
                "select * from staff, employee, org where employee.lastname in ('HAAS','THOMPSON', 'KWAN', 'GEYER', 'STERN', 'PULASKI', 'HENDERSON', 'SPENSER', 'LUCCHESSI', 'OCONNELL', 'QUINTANA', 'NICHOLLS', 'ADAMSON', 'PIANKA', 'YOSHIMURA', 'SCOUTTEN', 'WALKER', 'BROWN', 'JONES', 'LUTZ', 'JEFFERSON', 'MARINO', 'SMITH', 'JOHNSON', 'PEREZ', 'SCHNEIDER', 'PARKER', 'SMITH', 'SETRIGHT', 'MEHTA', 'LEE', 'GOUNOT') order by org.location,employee.lastname,staff.id"
            )
            cols = ifx_db.num_fields(result)
            j = 0
            row = ifx_db.fetch_both(result)
            while (row):
                for i in range(0, cols):
                    field = ifx_db.field_name(result, i)
                    value = row[ifx_db.field_name(result, i)]
                    if (value == None):
                        value = ''
                    print "%s:%s" % (field, value)
                print "---------"
                j += 1
                if (j == 10):
                    break

                row = ifx_db.fetch_both(result)

            ifx_db.close(conn)
            print "done"
        else:
            print ifx_db.conn_errormsg()
Exemplo n.º 6
0
    def run_test_102(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if (not conn):
            print ifx_db.conn_errormsg()

        server = ifx_db.server_info(conn)
        if ((server.DBMS_NAME[0:2] != "AS") and (server.DBMS_NAME != "DB2")
                and (server.DBMS_NAME[0:3] != "Inf")):
            result = ifx_db.exec_immediate(conn, "VALUES(1)")
            #throw :unsupported unless result
            if (not result):
                raise Exception('Unsupported')
            print ifx_db.num_fields(result)
        else:
            print '1'
        ifx_db.close(conn)
 def run_test_101(self):
     conn = ifx_db.connect(config.ConnStr, config.user, config.password)
     if conn:
         result = ifx_db.exec_immediate(
             conn, "insert into t_string values(123,1.222333,'one to one')")
         if result:
             cols = ifx_db.num_fields(result)
             print "col: %d" % cols
             rows = ifx_db.num_rows(result)
             print "affected row: %d" % rows
         result = ifx_db.exec_immediate(conn,
                                        "delete from t_string where a=123")
         if result:
             cols = ifx_db.num_fields(result)
             print "col: %d" % cols
             rows = ifx_db.num_rows(result)
             print "affected row: %d" % rows
     else:
         print "no connection"
Exemplo n.º 8
0
    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')
Exemplo n.º 9
0
    def run_test_100(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            ifx_db.autocommit(conn, ifx_db.SQL_AUTOCOMMIT_OFF)

            stmt = ifx_db.exec_immediate(
                conn, "SELECT * FROM animals ORDER BY breed")

            fields1 = ifx_db.num_fields(stmt)

            print "int(%d)" % fields1

            stmt = ifx_db.exec_immediate(
                conn, "SELECT name, breed FROM animals ORDER BY breed")
            fields2 = ifx_db.num_fields(stmt)

            print "int(%d)" % fields2

            stmt = ifx_db.exec_immediate(conn, "DELETE FROM animals")
            fields3 = ifx_db.num_fields(stmt)

            print "int(%d)" % fields3

            stmt = ifx_db.exec_immediate(
                conn, "INSERT INTO animals values (0, 'cat', 'Pook', 3.2)")
            fields4 = ifx_db.num_fields(stmt)

            print "int(%d)" % fields4

            stmt = ifx_db.exec_immediate(
                conn, "SELECT name, breed, 'TEST' FROM animals")
            fields5 = ifx_db.num_fields(stmt)

            print "int(%d)" % fields5

            ifx_db.rollback(conn)
        else:
            print "Connection failed."
  def run_test_125(self):
    conn = ifx_db.connect(config.ConnStr, config.user, config.password)
    server = ifx_db.server_info( conn )

    result = ifx_db.exec_immediate(conn, "SELECT * FROM sales")
    result2 = ifx_db.exec_immediate(conn, "SELECT * FROM staff")
    
    for i in range(0, ifx_db.num_fields(result)):
      print "%d:%s" % (i, ifx_db.field_name(result,i))
    
    print "-----"
    
    for i in range(0, ifx_db.num_fields(result2)):
      print "%d:%s" % (i, ifx_db.field_name(result2,i))
    
    print "-----"
    
    if (server.DBMS_NAME[0:3] == 'IDS'):
      print "Region:%s" % ifx_db.field_name(result, 'region')
    else:
      print "Region:%s" % ifx_db.field_name(result, 'REGION')
    print "5:%s" % ifx_db.field_name(result2, 5)
    def run_test_211(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        result = ifx_db.exec_immediate(conn, "select * from sales")

        i = 1

        while (i <= ifx_db.num_fields(result)):
            #printf("%d size %d\n",i, ifx_db.field_display_size(result,i) || 0)
            print "%d size %d" % (i, ifx_db.field_display_size(result, i) or 0)
            i += 1

        ifx_db.close(conn)
 def run_test_015(self):
   conn = ifx_db.connect(config.ConnStr, config.user, config.password)
   if conn:
     result = ifx_db.exec_immediate(conn,"insert into t_string values(123,1.222333,'one to one')")
     if result:
       cols = ifx_db.num_fields(result)
       # NOTE: Removed '\n' from the following and a few more prints here (refer to ruby test_015.rb)
       print "col:", cols
       rows = ifx_db.num_rows(result)
       print "affected row:", rows
     else:
       print ifx_db.stmt_errormsg()
     result = ifx_db.exec_immediate(conn,"delete from t_string where a=123")
     if result:
       cols = ifx_db.num_fields(result)
       print "col:", cols
       rows = ifx_db.num_rows(result)
       print "affected row:", rows
     else:
       print ifx_db.stmt_errormsg()
     ifx_db.close(conn)
   else:
     print "no connection:", ifx_db.conn_errormsg()
    def run_test_InsertRetrieveDateTimeTypeColumn(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            drop = 'DROP TABLE tab_datetime'
            result = ''
            try:
                result = ifx_db.exec_immediate(conn, drop)
            except:
                pass
            t_val = datetime.time(10, 42, 34)
            d_val = datetime.date(1981, 7, 8)
            #ts_val = datetime.datetime.today()
            ts_val = datetime.datetime(1981, 7, 8, 10, 42, 34, 10)
            server = ifx_db.server_info(conn)
            if (server.DBMS_NAME[0:3] == 'IDS'):
                statement = "CREATE TABLE tab_datetime (col1 DATETIME HOUR TO SECOND, col2 DATE, col3 DATETIME YEAR TO FRACTION(5))"
                result = ifx_db.exec_immediate(conn, statement)
                statement = "INSERT INTO tab_datetime (col1, col2, col3) values (?, ?, ?)"
                stmt = ifx_db.prepare(conn, statement)
                result = ifx_db.execute(stmt, (t_val, d_val, ts_val))
            else:
                statement = "CREATE TABLE tab_datetime (col1 TIME, col2 DATE, col3 TIMESTAMP)"
                result = ifx_db.exec_immediate(conn, statement)
                statement = "INSERT INTO tab_datetime (col1, col2, col3) values (?, ?, ?)"
                stmt = ifx_db.prepare(conn, statement)
                result = ifx_db.execute(stmt, (t_val, d_val, ts_val))

            statement = "SELECT * FROM tab_datetime"
            result = ifx_db.exec_immediate(conn, statement)

            for i in range(0, ifx_db.num_fields(result)):
                print str(i) + ":" + ifx_db.field_type(result, i)

            statement = "SELECT * FROM tab_datetime"
            stmt = ifx_db.prepare(conn, statement)
            rc = ifx_db.execute(stmt)
            result = ifx_db.fetch_row(stmt)
            while (result):
                row0 = ifx_db.result(stmt, 0)
                row1 = ifx_db.result(stmt, 1)
                row2 = ifx_db.result(stmt, 2)
                print type(row0), row0
                print type(row1), row1
                print type(row2), row2
                result = ifx_db.fetch_row(stmt)

            ifx_db.close(conn)
        else:
            print "Connection failed."
Exemplo n.º 14
0
 def run_test_016(self):
     conn = ifx_db.connect(config.ConnStr, config.user, config.password)
     if conn:
         result = ifx_db.exec_immediate(
             conn, "insert into t_string values(123,1.222333,'one to one')")
         if result:
             cols = ifx_db.num_fields(result)
             print "col:", cols
             rows = ifx_db.num_rows(result)
             print "affected row:", rows
         else:
             print ifx_db.stmt_errormsg()
         result = ifx_db.exec_immediate(conn,
                                        "delete from t_string where a=123")
         if result:
             cols = ifx_db.num_fields(result)
             print "col:", cols
             rows = ifx_db.num_rows(result)
             print "affected row:", rows
         else:
             print ifx_db.stmt_errormsg()
         ifx_db.close(conn)
     else:
         print "no connection:", ifx_db.conn_errormsg()
    def run_test_232(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        result = ifx_db.exec_immediate(conn, "select * from sales")

        for i in range(0, ifx_db.num_fields(result) + 1):
            field_name = ifx_db.field_name(result, i)
            field_type = ifx_db.field_type(result,
                                           ifx_db.field_name(result, i))
            print str(ifx_db.field_name(result, i)) + ":" + str(
                ifx_db.field_type(result, ifx_db.field_name(result, i)))

        print "-----"

        t = ifx_db.field_type(result, 99)
        print t

        t1 = ifx_db.field_type(result, "HELMUT")
        print t1
Exemplo n.º 16
0
    def run_test_103(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            result = ifx_db.exec_immediate(
                conn, "select * from org, project order by project.projname")
            cols = ifx_db.num_fields(result)
            j = 1
            row = ifx_db.fetch_tuple(result)
            while (row):
                print "%d) " % j
                for i in range(0, cols):
                    print "%s " % row[i]
                j += 1
                if (j > 10):
                    break
                row = ifx_db.fetch_tuple(result)
            ifx_db.close(conn)
        else:
            print ifx_db.conn_errormsg()
    def run_test_103(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            result = ifx_db.exec_immediate(
                conn,
                "select * from org, project order by project.projname,org.deptnumb"
            )
            cols = ifx_db.num_fields(result)
            j = 1
            row = ifx_db.fetch_tuple(result)
            while (row):
                print "%d) " % j
                for i in range(0, cols):
                    print "%s " % row[i]
                j += 1
                if (j > 10):
                    break
                row = ifx_db.fetch_tuple(result)
            ifx_db.close(conn)
        else:
            print ifx_db.conn_errormsg()


#__END__
#__IDS_EXPECTED__
#1) 10 Head Office 160 Corporate New York AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#2) 15 New England 50 Eastern Boston AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#3) 20 Mid Atlantic 10 Eastern Washington AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#4) 38 South Atlantic 30 Eastern Atlanta AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#5) 42 Great Lakes 100 Midwest Chicago AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#6) 51 Plains 140 Midwest Dallas AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#7) 66 Pacific 270 Western San Francisco AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#8) 84 Mountain 290 Western Denver AD3113 ACCOUNT PROGRAMMING D21 000270 2.00 1982-01-01 1983-02-01 AD3110
#9) 10 Head Office 160 Corporate New York AD3100 ADMIN SERVICES D01 000010 6.50 1982-01-01 1983-02-01
#10) 15 New England 50 Eastern Boston AD3100 ADMIN SERVICES D01 000010 6.50 1982-01-01 1983-02-01
Exemplo n.º 18
0
    def run_test_6792(self):
        conn = ifx_db.connect(config.ConnStr, config.user, config.password)

        if conn:
            drop = 'DROP TABLE table_6792'
            result = ''
            try:
                result = ifx_db.exec_immediate(conn, drop)
            except:
                pass

            t_val = '10:42:34'
            d_val = '1981-07-08'
            ts_val = '1981-07-08 10:42:34'
            ts_withT_val = '2013-06-06T15:30:39'

            server = ifx_db.server_info(conn)
            if (server.DBMS_NAME[0:3] == 'IDS'):
                statement = "CREATE TABLE table_6792 (col1 DATETIME HOUR TO SECOND, col2 DATE, col3 DATETIME YEAR TO SECOND, col4 DATETIME YEAR TO SECOND)"
                result = ifx_db.exec_immediate(conn, statement)
                statement = "INSERT INTO table_6792 (col1, col2, col3) values (?, ?, ?)"
                stmt = ifx_db.prepare(conn, statement)
                result = ifx_db.execute(stmt, (t_val, d_val, ts_val))
            else:
                statement = "CREATE TABLE table_6792 (col1 TIME, col2 DATE, col3 TIMESTAMP, col4 TIMESTAMP)"
                result = ifx_db.exec_immediate(conn, statement)
                statement = "INSERT INTO table_6792 (col1, col2, col3, col4) values (?, ?, ?, ?)"
                stmt = ifx_db.prepare(conn, statement)
                result = ifx_db.execute(stmt,
                                        (t_val, d_val, ts_val, ts_withT_val))

            statement = "SELECT * FROM table_6792"
            result = ifx_db.exec_immediate(conn, statement)

            for i in range(0, ifx_db.num_fields(result)):
                print str(i) + ":" + ifx_db.field_type(result, i)

            statement = "SELECT * FROM table_6792"
            stmt = ifx_db.prepare(conn, statement)
            rc = ifx_db.execute(stmt)
            result = ifx_db.fetch_row(stmt)
            while (result):
                row0 = ifx_db.result(stmt, 0)
                row1 = ifx_db.result(stmt, 1)
                row2 = ifx_db.result(stmt, 2)
                row3 = ifx_db.result(stmt, 3)
                print row0
                print row1
                print row2
                print row3
                result = ifx_db.fetch_row(stmt)

            ifx_db.close(conn)
        else:
            print "Connection failed."


#__END__
#__LUW_EXPECTED__
#0:time
#1:date
#2:timestamp
#3:timestamp
#10:42:34
#1981-07-08
#1981-07-08 10:42:34
#2013-06-06 15:30:39
#__ZOS_EXPECTED__
#0:time
#1:date
#2:timestamp
#3:timestamp
#10:42:34
#1981-07-08
#1981-07-08 10:42:34
#2013-06-06 15:30:39
#__SYSTEMI_EXPECTED__
#0:time
#1:date
#2:timestamp
#3:timestamp
#10:42:34
#1981-07-08
#1981-07-08 10:42:34
#2013-06-06 15:30:39
#__IDS_EXPECTED__
#0:time
#1:date
#2:timestamp
#3:timestamp
#10:42:34
#1981-07-08
#1981-07-08 10:42:34
#2013-06-06 15:30:39