def test_time(self): if self.conn._client.version < AVATICA_1_4_0: raise unittest.SkipTest( 'date/time/timestamp only works with Calcite >= 1.4.0') self.createTable("phoenixdb_test_tbl1", "id integer primary key, val time") with self.conn.cursor() as cursor: cursor.execute( "UPSERT INTO phoenixdb_test_tbl1 VALUES (1, '1970-01-01 12:01:02')" ) cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (2, NULL)") cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (3, ?)", [phoenixdb.Time(12, 1, 2)]) cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (4, ?)", [datetime.time(12, 1, 2)]) cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (5, ?)", [None]) cursor.execute( "SELECT id, val FROM phoenixdb_test_tbl1 ORDER BY id") self.assertEqual(cursor.fetchall(), [ [1, datetime.time(12, 1, 2)], [2, None], [3, datetime.time(12, 1, 2)], [4, datetime.time(12, 1, 2)], [5, None], ])
def test_time(self): self.createTable("phoenixdb_test_tbl1", "CREATE TABLE {table} (id integer primary key, val time)") with self.conn.cursor() as cursor: cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (1, '1970-01-01 12:01:02')") cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (2, NULL)") cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (3, ?)", [phoenixdb.Time(12, 1, 2)]) cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (4, ?)", [datetime.time(12, 1, 2)]) cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (5, ?)", [None]) cursor.execute("SELECT id, val FROM phoenixdb_test_tbl1 ORDER BY id") self.assertEqual(cursor.fetchall(), [ [1, datetime.time(12, 1, 2)], [2, None], [3, datetime.time(12, 1, 2)], [4, datetime.time(12, 1, 2)], [5, None], ])