Exemplo n.º 1
0
def get_attachments(db_path, phone_number):
    # Open database
    db = sqlite3.connect(db_path)
    cursor = db.cursor()
    # Tuple with phone number argument
    arg_tup = (phone_number,)
    # Get messages for phone number
    cursor.execute(get_attachments_sql_command(), arg_tup)
    # Process results
    for attachment in cursor:
        filepath = attachment[0]
        received_date = process_date(attachment[1], "%Y-%m_%d-%H_%M_%S")
        name = attachment[2]
        yield filepath, received_date, name
Exemplo n.º 2
0
    def get_messages(self):
        # No phone number provided to use for query
        if not self.identifier:
            return

        # Open database
        db = sqlite3.connect(self.dbPath)
        cursor = db.cursor()
        # Tuple with phone number argument
        arg_tup = (self.identifier, )
        # Get messages for phone number
        cursor.execute(self.get_messages_sql_command(), arg_tup)

        # Process results
        for msg in cursor:
            if not msg[2]:
                continue
            name = self.myName if msg[0] == 1 else self.otherName
            processed_date = process_date(msg[1])
            message = msg[2]
            yield name + self.SEPARATOR + processed_date + \
                self.SEPARATOR + message + "\n"