Last active
September 29, 2017 06:54
-
-
Save dado3212/27e4fdc1054eac8a4182b2810cd79ba8 to your computer and use it in GitHub Desktop.
Searches through all of your texts for one matching a string
This file contains 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
__author__ = "Alex Beals" | |
import sqlite3, markovify, codecs, warnings, os | |
# Handle errors from running on Python 2.7 (emoji support) | |
warnings.simplefilter("ignore") | |
print("Connecting to chat database...") | |
# Extract all of my texts from the 'db' file | |
conn = sqlite3.connect(os.path.expanduser("~/Library/Messages/chat.db")) | |
c = conn.cursor() | |
# String to search for | |
search_query = 'test' | |
c.execute('SELECT text FROM message WHERE text LIKE "%' + search_query + '%"') | |
texts = c.fetchall() | |
for text in texts: | |
print text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment