Last active
December 2, 2016 16:05
-
-
Save scien/cc38b2cba28bbbb30054 to your computer and use it in GitHub Desktop.
iMessages Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How to connect | |
| > sqlite3 ~/Library/Messages/chat.db | |
| Helpful Commands | |
| sqlite> .help | |
| sqlite> .tables | |
| sqlite> .headers off | |
| sqlite> .headers on | |
| sqlite> .mode line | |
| sqlite> .schema message | |
| Find a specific friend by phone number | |
| sqlite> SELECT ROWID, id FROM handle WHERE id like '+1802%'; // area code 802 phone numbers | |
| Find message history with a specific friend | |
| sqlite> /* let's assume the ROWID from the previous query was 41 */ | |
| sqlite> .mode list | |
| sqlite> SELECT ROWID, date, is_from_me, text FROM message WHERE handle_id=41 ORDER BY date; | |
| Find a specific message from a friend | |
| sqlite> SELECT ROWID, date, is_from_me, text FROM message WHERE handle_id=41 and text like '%something they said%' ORDER BY date; | |
| sqlite> /* then look at the ROWID. We'll use 7005 for this example */ | |
| sqlite> /* then we can grab the next 10 messages from that conversation */ | |
| sqlite> select ROWID, date, is_from_me, text from message where handle_id = 41 and ROWID >= 7005 ORDER BY date LIMIT 10; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment