Home > Net >  Only able to access SQLite3 database through Terminal
Only able to access SQLite3 database through Terminal

Time:07-29

I wrote a Node script to access Safari's iCloud Tabs database, found here on a Mac: ~/Library/Containers/com.apple.Safari/Data/Library/Safari/CloudTabs.db.

When I run the script through Terminal, it's able to access the database just fine. Or when I'm in Terminal, and I open the database with sqlite3 CloudTabs.db, I can view the tables just fine with .tables.

However, if I run the Node script through another program, such as Alfred, I get the following error:

[Error: SQLITE_CANTOPEN: unable to open database file] {
  errno: 14,
  code: 'SQLITE_CANTOPEN'
}

And if I open the database file directly from the Mac Finder with DB Browser for SQLite, then it says "Could not open database file." (I've read that perhaps this is because the file is located in a hidden directory?)

Through both Terminal and Alfred, USER is set to gary, and even if I try source ~/.bash_profile before running my Node script through Alfred, I get the same error.

Why am I only able to open this particular SQLite database in some ways, but can't open it in other ways? How is SQLite able to restrict access to its database selectively like this?

My primary question is, how can I make it possible to access this SQLite database by running the script through Alfred?

CodePudding user response:

To fix the problem on a Mac to access restricted database files, I resolved the issue by going to "System Preferences > Security & Privacy > Privacy > Full Disk Access" and adding and checkmarking the relevant apps, which would be Alfred and SQLite DB Browser, in my case.

  • Related