Unable to open database file in sqlite3 in Python

I am working on an application in python that shows Brave browser history. I have located the file which contains it and when I try to open the database I keep getting the error:

sqlite3.OperationalError: unable to open database file

Would be great if it told you why. I’ve looked at a few posts of those with my same problem, but couldn’t find any solutions that worked. So what the heck is going on here?

Here’s my code:

import sqlite3
import os

username = os.getlogin()
con = sqlite3.connect("/Users/" + username + "/Library/Application Support/BraveSoftware/Brave-Browser/Default/History")
cur = con.cursor()

for row in cur.execute('SELECT * FROM species;'):
    print(row)

con.close()

My installation is Python 3.11.4

I have tried changing the History file permissions, and the enclosing folders which did not work.

  • make sure database path is correct

    – 

  • I think you haven’t set in your path, the database filename… If I’m wrong go with your explorer in the file and copy the path and paste it here to understand better what’s going on.

    – 

  • I would expect the filename to have an extension. If you found the file in Finder, it might be set not to show extensions.

    – 

  • Try History.db

    – 

  • Or use ls ~/'Library/Application Support/BraveSoftware/Brave-Browser/Default/History'* in Terminal.

    – 

Leave a Comment