def __resolvePos(st, li): if li == None: return pos = 0 if type(li) != list: li = [li] for l in li: pos = pos + 1 if l == None: st.setObject(pos, None) elif type(l) is int or type(l) is long: st.setLong(pos, l) elif type(l) is float: st.setDouble(pos, l) elif type(l) is datetime.date: d = con.toDate(l) dsql = Date(d.getTime()) st.setDate(pos, dsql) else: st.setString(pos, l)
def test_datetime(self): conn = None try: conn = connect(self.jdbc_url) cursor = conn.cursor() cursor.execute(''' create table dt ( one date, two date, three time, four time, five timestamp ) ''') cursor.execute( 'insert into dt values (?, ?, ?, ?, ?)', dbapi.Date(2012, 6, 1), Date(1338534000000), Time(1), dbapi.Time(1, 2, 3), dbapi.Timestamp(2012, 6, 1, 1, 2, 3), ) cursor.execute('select * from dt') # crazy sqllite doesn't have normal date types. # this will force jep.jdbc to interpret the result correctly for this # test. cursor.description = ( ('one', 91, None, None, None, None, True), ('two', 91, None, None, None, None, True), ('three', 92, None, None, None, None, True), ('four', 92, None, None, None, None, True), ('five', 93, None, None, None, None, True), ) row = cursor.fetchone() self.assertEqual(row[0].toString(), '2012-06-01') self.assertEqual(row[1].getTime(), 1338534000000) self.assertEqual(row[2].getTime(), 1) self.assertEqual(row[3].toString(), '01:02:03') self.assertEqual(row[4].toString(), '2012-06-01 01:02:03.0') cursor.close() finally: if conn: conn.close()
def test_date(self): self.assertEquals(datetime.date(2008, 5, 29), Py.newDate(Date(108, 4, 29))) self.assertEquals(datetime.date(1999, 1, 1), Py.newDate(Date(99, 0, 1)))
def convert_timestamp_to_date(timestamp): if timestamp: return Date(timestamp.getTime()) return None
fdmAPI.log( ImpFormatMapDetRS.getString("IMPFLDFIELDNAME") + ImpFormatMapDetRS.getString("IMPFLDFIXEDTEXT") + str(ImpFormatMapDetRS.getInt("IMPFLDSTARTPOS")) + str(ImpFormatMapDetRS.getInt("IMPFLDLENGTH")) + ImpFormatMapDetRS.getString("IMPFLDSOURCECOLNAME")) ImpFormatMapDetRS.close #String getCategoryMap(BigDecimal pCatKey,String pApplicationName) #there seems to be a mismatch in the parameter list when using Catkey, "Comm7D" it gives invalid column index CatKey = BigDecimal(7) CatMap = fdmAPI.getCategoryMap(CatKey, "COMM7D") fdmAPI.log("Category Mapping is " + str(CatMap)) #Map getPeriodDetail(Date pPeriodKey,String pApplicationName) -- if using parameters as App, Periodkey then get invalid column index d = Date.valueOf("2003-03-01") fdmAPI.log(str(d)) PeriodDet = fdmAPI.getPeriodDetail(d, "COMM7D") fdmAPI.log("Period details are " + str(PeriodDet)) #ResultSet getLocationDetails(BigDecimal pPartitionKey) p_partitionkey = BigDecimal(32) LocDetailsRS = fdmAPI.getLocationDetails(p_partitionkey) resultSetMetaData = LocDetailsRS.getMetaData() for i in range(1, resultSetMetaData.getColumnCount() + 1): fdmAPI.log(resultSetMetaData.getColumnName(i)) fdmAPI.log("Location details ") while (LocDetailsRS.next()): fdmAPI.log( LocDetailsRS.getString("PARTNAME") + LocDetailsRS.getString("PARTIMPGROUP") +