Exemplo n.º 1
0
 def testExecuteWithParamsMismatch(self):
     with self.assertRaises(teradata.InterfaceError) as cm:
         with tdodbc.connect(system=system, username=self.username,
                             password=self.password,
                             autoCommit=True) as conn:
             self.assertIsNotNone(conn)
             with conn.cursor() as cursor:
                 cursor.execute(
                     "CREATE TABLE testExecuteWithParamsMismatch (id INT, "
                     "name VARCHAR(128), dob TIMESTAMP)")
                 cursor.execute(
                     "INSERT INTO testExecuteWithParamsMismatch "
                     "VALUES (?, ?, ?)", (1, "TEST", ))
     self.assertEqual(
         cm.exception.code, "PARAMS_MISMATCH", cm.exception.msg)
Exemplo n.º 2
0
 def testExecuteWithParamsMismatch(self):
     with self.assertRaises(teradata.InterfaceError) as cm:
         with tdodbc.connect(system=system,
                             username=self.username,
                             password=self.password,
                             autoCommit=True) as conn:
             self.assertIsNotNone(conn)
             with conn.cursor() as cursor:
                 cursor.execute(
                     "CREATE TABLE testExecuteWithParamsMismatch (id INT, "
                     "name VARCHAR(128), dob TIMESTAMP)")
                 cursor.execute(
                     "INSERT INTO testExecuteWithParamsMismatch "
                     "VALUES (?, ?, ?)", (
                         1,
                         "TEST",
                     ))
     self.assertEqual(cm.exception.code, "PARAMS_MISMATCH",
                      cm.exception.msg)
Exemplo n.º 3
0
    def testCursorBasics(self):
        with tdodbc.connect(system=system,
                            username=self.username,
                            password=self.password,
                            autoCommit=True) as conn:
            self.assertIsNotNone(conn)
            with conn.cursor() as cursor:
                count = 0
                for row in cursor.execute("SELECT * FROM DBC.DBCInfo"):
                    self.assertEqual(len(row), 2)
                    self.assertIsNotNone(row[0])
                    self.assertIsNotNone(row['InfoKey'])
                    self.assertIsNotNone(row['infokey'])
                    self.assertIsNotNone(row.InfoKey)
                    self.assertIsNotNone(row.infokey)
                    self.assertIsNotNone(row[1])
                    self.assertIsNotNone(row['InfoData'])
                    self.assertIsNotNone(row['infodata'])
                    self.assertIsNotNone(row.infodata)
                    self.assertIsNotNone(row.InfoData)

                    row[0] = "test1"
                    self.assertEqual(row[0], "test1")
                    self.assertEqual(row['InfoKey'], "test1")
                    self.assertEqual(row.infokey, "test1")

                    row['infokey'] = "test2"
                    self.assertEqual(row[0], "test2")
                    self.assertEqual(row['InfoKey'], "test2")
                    self.assertEqual(row.infokey, "test2")

                    row.infokey = "test3"
                    self.assertEqual(row[0], "test3")
                    self.assertEqual(row['InfoKey'], "test3")
                    self.assertEqual(row.InfoKey, "test3")
                    count += 1

                self.assertEqual(cursor.description[0][0], "InfoKey")
                self.assertEqual(cursor.description[0][1], tdodbc.STRING)
                self.assertEqual(cursor.description[1][0], "InfoData")
                self.assertEqual(cursor.description[1][1], tdodbc.STRING)
                self.assertEqual(count, 3)
Exemplo n.º 4
0
    def testCursorBasics(self):
        with tdodbc.connect(system=system, username=self.username,
                            password=self.password, autoCommit=True) as conn:
            self.assertIsNotNone(conn)
            with conn.cursor() as cursor:
                count = 0
                for row in cursor.execute("SELECT * FROM DBC.DBCInfo"):
                    self.assertEqual(len(row), 2)
                    self.assertIsNotNone(row[0])
                    self.assertIsNotNone(row['InfoKey'])
                    self.assertIsNotNone(row['infokey'])
                    self.assertIsNotNone(row.InfoKey)
                    self.assertIsNotNone(row.infokey)
                    self.assertIsNotNone(row[1])
                    self.assertIsNotNone(row['InfoData'])
                    self.assertIsNotNone(row['infodata'])
                    self.assertIsNotNone(row.infodata)
                    self.assertIsNotNone(row.InfoData)

                    row[0] = "test1"
                    self.assertEqual(row[0], "test1")
                    self.assertEqual(row['InfoKey'], "test1")
                    self.assertEqual(row.infokey, "test1")

                    row['infokey'] = "test2"
                    self.assertEqual(row[0], "test2")
                    self.assertEqual(row['InfoKey'], "test2")
                    self.assertEqual(row.infokey, "test2")

                    row.infokey = "test3"
                    self.assertEqual(row[0], "test3")
                    self.assertEqual(row['InfoKey'], "test3")
                    self.assertEqual(row.InfoKey, "test3")
                    count += 1

                self.assertEqual(cursor.description[0][0], "InfoKey")
                self.assertEqual(cursor.description[0][1], tdodbc.STRING)
                self.assertEqual(cursor.description[1][0], "InfoData")
                self.assertEqual(cursor.description[1][1], tdodbc.STRING)
                self.assertEqual(count, 3)
Exemplo n.º 5
0
 def testConnect(self):
     conn = tdodbc.connect(system=system,
                           username=self.username,
                           password=self.password)
     self.assertIsNotNone(conn)
     conn.close()
Exemplo n.º 6
0
 def testBadCredentials(self):
     with self.assertRaises(tdodbc.DatabaseError) as cm:
         tdodbc.connect(system=system, username="******", password="******")
     self.assertEqual(cm.exception.code, 8017, cm.exception.msg)
Exemplo n.º 7
0
 def testSystemNotFound(self):
     with self.assertRaises(tdodbc.DatabaseError) as cm:
         tdodbc.connect(system="continuum.td.teradata.com",
                        username=self.username,
                        password=self.password)
     self.assertTrue("08004" in cm.exception.msg, cm.exception)
Exemplo n.º 8
0
 def testConnect(self):
     conn = tdodbc.connect(
         system=system, username=self.username, password=self.password)
     self.assertIsNotNone(conn)
     conn.close()
Exemplo n.º 9
0
 def testBadCredentials(self):
     with self.assertRaises(tdodbc.DatabaseError) as cm:
         tdodbc.connect(system=system, username="******", password="******")
     self.assertEqual(cm.exception.code, 8017, cm.exception.msg)
Exemplo n.º 10
0
 def testSystemNotFound(self):
     with self.assertRaises(tdodbc.DatabaseError) as cm:
         tdodbc.connect(system="continuum.td.teradata.com",
                        username=self.username, password=self.password)
     self.assertTrue("08004" in cm.exception.msg, cm.exception)