def query(self, statement):
     self.db_view = e32db.Db_view()
     self.db_view.prepare(self.db, unicode(statement))
     no_of_rows = self.db_view.count_line()
     self.db_view.first_line()
     data = []
     for row_no in xrange(no_of_rows):
         self.db_view.get_line()
         line = []
         # Will contain col_type, col_raw, col_rawtime, format_rawtime
         misc_testdata = []
         for column_no in xrange(1, self.db_view.col_count() + 1):
             line.append(self.db_view.col(column_no))
             column_type = self.db_view.col_type(column_no)
             misc_testdata.append(column_type)
             if not self.db_view.is_col_null(column_no):
                 misc_testdata.append(self.db_view.col_length(column_no))
             if column_type != 15:
                 misc_testdata.append(repr(self.db_view.col_raw(column_no)))
             if column_type == 10:
                 misc_testdata.append(
                                  repr(self.db_view.col_rawtime(column_no)))
                 misc_testdata.append(repr(e32db.format_rawtime(
                                      self.db_view.col_rawtime(column_no))))
         data.append(tuple(line))
         self.db_view.next_line()
     del self.db_view
     return data, misc_testdata
Esempio n. 2
0
File: orm.py Progetto: nesl/ecopda
 def __init__(self, db, id=None, **kw):
     self.db = db
     self.dbv = e32db.Db_view()
     if id is None:
         self.id = self._insert(**kw)
     else:
         self.id = id
Esempio n. 3
0
 def __init__(self,butterfly_app,db):
     self.butterfly_app = butterfly_app
     self.listbox = None
     self.ListID = []
     self.db = db
     self.dbv = e32db.Db_view()
     self.selected = 0
Esempio n. 4
0
 def __init__(self, dbpath):
     self.db = e32db.Dbms()
     self.dbv = e32db.Db_view()
     self.reset_counters()
     try:
         self.db.open(unicode(dbpath))
     except:
         self.db.create(unicode(dbpath))
         self.db.open(unicode(dbpath))
Esempio n. 5
0
File: trap.py Progetto: nesl/ecopda
 def __init__(self,butterfly_app, db):
     self.butterfly_app = butterfly_app
     self.listbox = None
     self.ListID = []
     self.db = db
     self.fname = u'e:\\butterfly_data\\traps.xml'
     self.selected = 0
     self.viewby = 'date Desc'
     self.child_db =[] # this must be set from outside
     self.dbv = e32db.Db_view()
     self.parent_dict = {}
Esempio n. 6
0
 def get_all_entries(self):
     dbv = e32db.Db_view()
     dbv.prepare(self.native_db, u"SELECT * from events ORDER BY date DESC")
     dbv.first_line()
     results = []
     for i in range(dbv.count_line()):
         dbv.get_line()
         e = SportsDiaryEntry(dbv)
         results.append(e)
         dbv.next_line()
     return results
Esempio n. 7
0
File: orm.py Progetto: nesl/ecopda
 def select(cls, db, where=None, orderby=None):
     q = 'SELECT id FROM '+ cls.__name__
     if where:
         q += ' WHERE '+where
     if orderby:
         q += ' ORDER BY '+orderby
     dbv = e32db.Db_view()  # need its own cursor
     dbv.prepare(db, unicode(q))
     dbv.first_line()
     for i in range(dbv.count_line()):
         dbv.get_line()
         yield cls(db, dbv.col(1))
         dbv.next_line()
Esempio n. 8
0
 def _query(self, statement):
     """Execute a query and return results."""
     #print "Executing query: %s"%statement
     DBV = e32db.Db_view()
     DBV.prepare(self.db, unicode(statement))
     n = DBV.count_line()
     DBV.first_line()
     data = []
     for i in xrange(n):
         DBV.get_line()
         line = []
         for j in xrange(DBV.col_count()):
             line.append(DBV.col(1 + j))
         data.append(tuple(line))
         DBV.next_line()
     del DBV
     return data
Esempio n. 9
0
def query(db, statement):
    DBV = e32db.Db_view()
    DBV.prepare(db, unicode(statement))
    n = DBV.count_line()
    DBV.first_line()
    data = []
    for i in xrange(n):
        DBV.get_line()
        line = []
        for j in xrange(DBV.col_count()):
            line.append(DBV.col(1 + j))
            t = DBV.col_type(1 + j)
            print "Column type: %d" % t
            if t != 15:
                print "Raw value: %s" % repr(DBV.col_raw(1 + j))
            if t == 10:
                print "Raw time: %s" % repr(DBV.col_rawtime(1 + j))
                print "Formatted: %s" % e32db.format_rawtime(
                    DBV.col_rawtime(1 + j))

        data.append(tuple(line))
        DBV.next_line()
    del DBV
    return data
Esempio n. 10
0
 def gen_view(self, command):
     view = e32db.Db_view()
     view.prepare(self.db, command)
     return view