def test_date_dictarray(self):
if np.__version__ < "1.7": return
self.cursor.execute("create table t1(a int, b date, c int)")
dates = [date(2008, 4, i) for i in range(1,11)]
npdates = np.array(dates, dtype='datetime64[D]')
params = [ (i, dates[i-1], i) for i in range(1,11) ]
npparams = [ (i, npdates[i-1], i) for i in range(1,11) ]
self.cursor.executemany("insert into t1(a, b, c) values (?,?,?)", params)
self.cursor.execute("select a, b, c from t1 order by a")
rows = self.cursor.fetchdictarray()
for param, row in zip(npparams, zip(rows['a'], rows['b'], rows['c'])):
self.assertEqual(param[0], row[0])
self.assertEqual(param[1], row[1])
self.assertEqual(param[2], row[2])
评论列表
文章目录