示例#1
0
 def test_date(self):
     self.createTable("phoenixdb_test_tbl1", "CREATE TABLE {table} (id integer primary key, val date)")
     with self.conn.cursor() as cursor:
         cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (1, '2015-07-12 00:00:00')")
         cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (3, ?)", [phoenixdb.Date(2015, 7, 12)])
         cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (4, ?)", [datetime.date(2015, 7, 12)])
         cursor.execute("SELECT id, val FROM phoenixdb_test_tbl1 ORDER BY id")
         self.assertEqual(cursor.fetchall(), [
             [1, datetime.date(2015, 7, 12)],
             [3, datetime.date(2015, 7, 12)],
             [4, datetime.date(2015, 7, 12)],
         ])
示例#2
0
 def test_date(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 date")
     with self.conn.cursor() as cursor:
         cursor.execute(
             "UPSERT INTO phoenixdb_test_tbl1 VALUES (1, '2015-07-12 00:00:00')"
         )
         cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (3, ?)",
                        [phoenixdb.Date(2015, 7, 12)])
         cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (4, ?)",
                        [datetime.date(2015, 7, 12)])
         cursor.execute(
             "SELECT id, val FROM phoenixdb_test_tbl1 ORDER BY id")
         self.assertEqual(cursor.fetchall(), [
             [1, datetime.date(2015, 7, 12)],
             [3, datetime.date(2015, 7, 12)],
             [4, datetime.date(2015, 7, 12)],
         ])