def _query_element_metadata(self, elemnt_id):
     sql = '''SELECT value FROM attributes WHERE element_id= '{id}' 
         AND name = '{begin}';'''.format(id= elemnt_id, begin= self.BEGIN_KEY)
     
     timestamp = _m.logbook_query(sql)[0][0]
     print timestamp
     
     sql = '''SELECT tag FROM elements WHERE element_id= %s''' %elemnt_id
     title = _m.logbook_query(sql)[0][0]
     print title
     
     return timestamp, title
    def _query_element_metadata(self, elemnt_id):
        sql = '''SELECT value FROM attributes WHERE element_id= '{id}' 
            AND name = '{begin}';'''.format(id=elemnt_id, begin=self.BEGIN_KEY)

        timestamp = _m.logbook_query(sql)[0][0]
        print timestamp

        sql = '''SELECT tag FROM elements WHERE element_id= %s''' % elemnt_id
        title = _m.logbook_query(sql)[0][0]
        print title

        return timestamp, title
    def _search_logbook(self):
        if self.CaseSensitivity:
            n = self.AttributeName
            v = self.AttributeValue
            condition1 = 'name'
            condition2 = 'value'
            
        else:
            n = self.AttributeName.lower()
            v = self.AttributeValue.lower()
            condition1 = 'LOWER(name)'
            condition2 = 'LOWER(value)'

        where = "{c1} LIKE '%{n}%' AND {c2} LIKE '%{v}%';".format(c1= condition1, n=n, c2= condition2, v=v)
        
        sql = '''SELECT element_id
                FROM attributes
                WHERE %s''' %where
        
        result = _m.logbook_query(sql)
        return [t[0] for t in result]
    def _search_logbook(self):
        if self.CaseSensitivity:
            n = self.AttributeName
            v = self.AttributeValue
            condition1 = 'name'
            condition2 = 'value'

        else:
            n = self.AttributeName.lower()
            v = self.AttributeValue.lower()
            condition1 = 'LOWER(name)'
            condition2 = 'LOWER(value)'

        where = "{c1} LIKE '%{n}%' AND {c2} LIKE '%{v}%';".format(
            c1=condition1, n=n, c2=condition2, v=v)

        sql = '''SELECT element_id
                FROM attributes
                WHERE %s''' % where

        result = _m.logbook_query(sql)
        return [t[0] for t in result]