예제 #1
0
 def sql_add(self):
     sql = "INSERT INTO events (date, duration, distance, sport, comment) VALUES (#%s#,%d,%d,%d,'%s')"%(
         e32db.format_time(self.timestamp),
         self.duration,
         self.distance,
         self.sport,
         self.comment)
     return unicode(sql)
 def sql_add(self):
     sql = "INSERT INTO events (date, duration, distance, sport, comment) VALUES (#%s#,%d,%d,%d,'%s')"%(
         e32db.format_time(self.timestamp),
         self.duration,
         self.distance,
         self.sport,
         self.comment)
     return unicode(sql)
def RefreshScheduledListBox():
	Entries = []
	
	if len(ScheduledSMSList) > 0:
		for x in ScheduledSMSList:
			Text = u''
			
			Text = x.Contacts[0][0]
			
			if len(x.Contacts) > 1:
				Text = Text + u'...'
				
			Text = Text + u': '
			Text = Text + x.Message
			
			RepeatString = u''
			if 0 != x.Repeat:
				if 1 == x.Repeat:
					RepeatString = u' (Hourly)'
				if 2 == x.Repeat:
					RepeatString = u' (Daily)'					
				if 3 == x.Repeat:
					RepeatString = u' (Weekly)'					
				if 4 == x.Repeat:
					RepeatString = u' (Fortnightly)'					
				if 5 == x.Repeat:
					RepeatString = u' (Monthly)'					
				if 6 == x.Repeat:
					RepeatString = u' (Yearly)'					
				
			Entries.append((Text, unicode(format_time(x.Date + x.Time) + RepeatString)))
			
		ScheduledListBox.set_list(Entries)

		if TabIndex == 0:
			appuifw.app.menu = [(u'Add', OnAddScheduledSMS), (u'Delete', OnDeleteScheduledSMS), (u'Edit', OnEditScheduledSMS), (u'Exit application', OnExit)]
	else:
		ScheduledListBox.set_list([(u'Empty', u'')])
		
		if TabIndex == 0:
			appuifw.app.menu = [(u'Add', OnAddScheduledSMS), (u'Exit application', OnExit)]	
def RefreshHistoryListBox():
	Entries = []
	
	if len(HistorySMSList) > 0:
		for x in HistorySMSList:
			Text = u''
			
			Text = x.Contacts[0][0]
			
			if len(x.Contacts) > 1:
				Text = Text + u'...'
				
			Text = Text + u': '
			Text = Text + x.Message
			
			RepeatString = u''
			if 0 != x.Repeat:
				if 1 == x.Repeat:
					RepeatString = u' (Hourly)'
				if 2 == x.Repeat:
					RepeatString = u' (Daily)'					
				if 3 == x.Repeat:
					RepeatString = u' (Weekly)'					
				if 4 == x.Repeat:
					RepeatString = u' (Fortnightly)'					
				if 5 == x.Repeat:
					RepeatString = u' (Monthly)'					
				if 6 == x.Repeat:
					RepeatString = u' (Yearly)'					
				
			Entries.append((Text, unicode(format_time(x.Date + x.Time) + RepeatString)))
			
		HistoryListBox.set_list(Entries)
		
		appuifw.app.menu = [(u'Clear', OnClearHistorySMSs), (u'Exit application', OnExit)]
	else:
		HistoryListBox.set_list([(u'Empty', u'')])
		
		appuifw.app.menu = [(u'Exit application', OnExit)]
 def sql_delete(self):
     sql = "DELETE FROM events WHERE date=#%s#"%\
           e32db.format_time(self.timestamp)
     return unicode(sql)
예제 #6
0
        ('tinyint', '1'),
        ('unsigned tinyint', '1'),
        ('smallint', '1'),
        ('unsigned smallint', '1'),
        ('integer', '1'),
        ('unsigned integer', '1'),
        ('counter', '1'),
        ('bigint', str(2**60)),
        ('real', '1.234'),
        ('float', '1.234'),
        ('double', '1.234'),
        ('double precision', '1.234'),
        ('timestamp', "#20-oct/2004#"),
        ('time', "#20-oct/2004#"),
        ('date', "#20-oct/2004#"),
        ('date', "#%s#" % e32db.format_time(0)),
        ('date', "#%s#" % e32db.format_time(12345678)),
        ('char(8)', "'foo'"),
        ('varchar(8)', "'bar'"),
        ('long varchar', "'baz'"),
        #       ('binary(8)',"'quux'") # not supported...
    )

    for k in range(len(dat)):
        dbexec('create table t%d (x %s)' % (k, dat[k][0]))
        dbexec('insert into t%d values (%s)' % (k, dat[k][1]))
        print query(db, u'select * from t%d' % k)
finally:
    print "Closing database."
    db.close()
예제 #7
0
def show_time():

    texto.add(e32db.format_time(time.time()) + u'\n')
    def test_data_types(self):
        data_types_testdata = \
              (('bit', '1'),
               ('tinyint', '2'),
               ('unsigned tinyint', '3'),
               ('smallint', '4'),
               ('unsigned smallint', '5'),
               ('integer', '6'),
               ('unsigned integer', '7'),
               ('counter', '8'),
               ('bigint', str(2**60)),
               ('real', '4.224'),
               ('float', '5.784'),
               ('double', '4.135'),
               ('double precision', '2.5664'),
               ('timestamp', "#20-oct/2004#"),
               ('time', "#20-oct/2004#"),
               ('date', "#20-oct/2004#"),
               ('date', "#%s#" % e32db.format_time(0)),
               ('date', "#%s#" % e32db.format_time(12345678)),
               ('char(8)', "'foo'"),
               ('varchar(8)', "'bar'"),
               ('long varchar', "'baz'"))

        # Format : ([(<query output>)], [misc_testdata])
        # where misc_testdata has : col_type, col_length, col_raw values.
        # For the time and date formats output of col_rawtime and
        # format_rawtime values are also appended.
        query_expected_output = \
           (([(1, )], [0, 1, "'\\x01\\x00\\x00\\x00'"]),
            ([(2, )], [1, 1, "'\\x02\\x00\\x00\\x00'"]),
            ([(3, )], [2, 1, "'\\x03\\x00\\x00\\x00'"]),
            ([(4, )], [3, 1, "'\\x04\\x00\\x00\\x00'"]),
            ([(5, )], [4, 1, "'\\x05\\x00\\x00\\x00'"]),
            ([(6, )], [5, 1, "'\\x06\\x00\\x00\\x00'"]),
            ([(7, )], [6, 1, "'\\x07\\x00\\x00\\x00'"]),
            ([(8, )], [6, 1, "'\\x08\\x00\\x00\\x00'"]),
            ([(1152921504606846976L, )],
             [7, 1, "'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x10'"]),
            ([(4.2239999771118164,)], [8, 1, "'\\x02+\\x87@'"]),
            ([(5.784, )], [9, 1, '\'\\x89A`\\xe5\\xd0"\\x17@\'']),
            ([(4.135, )], [9, 1, "'\\n\\xd7\\xa3p=\\x8a\\x10@'"]),
            ([(2.5664, )], [9, 1, "'\\x9c\\xa2#\\xb9\\xfc\\x87\\x04@'"]),
            ([(1098210600.0, )],
             [10, 1, "'\\x00 \\x0f\\xc0\\x88\\xc4\\xe0\\x00'",
             '63266486400000000L', "u'20-10-2004 12:00:00.000000 am'"]),
            ([(1098210600.0, )],
             [10, 1, "'\\x00 \\x0f\\xc0\\x88\\xc4\\xe0\\x00'",
             '63266486400000000L', "u'20-10-2004 12:00:00.000000 am'"]),
            ([(1098210600.0, )],
             [10, 1, "'\\x00 \\x0f\\xc0\\x88\\xc4\\xe0\\x00'",
             '63266486400000000L', "u'20-10-2004 12:00:00.000000 am'"]),
            ([(0.0, )], [10, 1, "'\\x00\\x86[\\xab\\xb7\\xdd\\xdc\\x00'",
                   '62168275800000000L', "u'01-01-1970 5:30:00.000000 am'"]),
            ([(12345678.0, )],
             [10, 1, "'\\x80\\xf5\\x1b\\x1f\\xf2\\xe8\\xdc\\x00'",
                   '62180621478000000L', "u'24-05-1970 2:51:18.000000 am'"]),
            ([(u'foo', )], [12, 3, "'f\\x00o\\x00o\\x00'"]),
            ([(u'bar', )], [12, 3, "'b\\x00a\\x00r\\x00'"]),
            ([(u'baz', )], [15, 3]))

        for k in range(len(data_types_testdata)):
            self.db.execute(u'create table t%d (x %s)' %
                             (k, data_types_testdata[k][0]))
            self.db.execute(u'insert into t%d values (%s)' %
                             (k, data_types_testdata[k][1]))
            query_output = self.query(u'select * from t%d' % k)
            self.assertEqual(query_output, query_expected_output[k])
예제 #9
0
def getDate(timeValue):
    dateTime = e32db.format_time(timeValue).split()
    return dateTime[0]
예제 #10
0
 def sql_delete(self):
     sql = "DELETE FROM events WHERE date=#%s#"%\
           e32db.format_time(self.timestamp)
     return unicode(sql)