Unable to query chat.db

Is it possible to read messages from chat.db inside a MacOS app?

I'm developing a MacOS app, I'm able to successfully connect to ~/Library/Messages/chat.db but when I try to run a query I get Error preparing select: authorization denied

I know other apps like TablePlus are able to read chat.db but these apps are outside of iOS.

Thanks in advance!

Replies

Looking at the big picture, it seems like you’re trying to read the messages being managed by the Messages app. There’s no API to do that. Moreover, the location and format of the message database is not considered API, and if you built an app based on that you are likely to run into compatibility problems moving forward.

I try to run a query I get … authorization denied

Yep. I believe that’s protected by MAC, as defined in On File System Permissions.

Note that Messages has an AppleScript interface, so you can get some information from it that way. I don’t think it offers access to the individual messages though.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I know there is no API but chat.db is a simple sqlite db. I find it difficult to believe that Apple would not let you query this db when external apps like TablePlus can but if thats true, I guess I need to make my app outside of Apple. :(