0

I know I have to be making a dumb mistake here...

            checksum = self.hashItem(os.path.join(root, filename))
            print checksum
            query = 'SELECT * FROM tracked_file WHERE md5 = ?'
            self.con.execute(query, [str(checksum)])
            results = self.cur.fetchall()
            print results

Here's the table structure

'CREATE TABLE if not exists tracked_file (filename TEXT, filepath TEXT, date_created TEXT, date_modified TEXT, file_size INTEGER, sha1 TEXT, md5 TEXT, catalog_date TEXT, archive_date TEXT);'

and the output of the script is showing md5 values I can verify are in the table manually.

48f3dd221a0cb5284c678b3aff24d668 [] ff12917ca9ec1cf8bc913efdf7f3ade7 [] 7b5cf763ef1a75eceb0bb960421a3ec2 [] 390228bde6440ed38f45dbf8ea09d860 [] c10e728e60e580b0eb97c3ab705b8fb9

1 Answer 1

2

You're running the query against the connection:

self.con.execute(query, [str(checksum)])

But trying to get results from the cursor:

results = self.cur.fetchall()

The connection's execute method creates an intermediate cursor to run the SQL, but this won't be the same cursor you've created and stored in self.cur

Try:

self.cur.execute(query, [str(checksum)])
results = self.cur.fetchall()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.