I am running a shell script in Tasker (Android) for querying my emails, but it always returns nothing.
sqlite3 /data/data/com.google.android.gm/databases/mailstore.MYEMAIL@gmail.com.db "SELECT fromAddress || '@|@' || dateSentMs || '@|@' || Subject || '@|@' || snippet FROM messages m LEFT JOIN message_labels ml ON m._id = ml.message_messageId JOIN labels l ON l._id = ml.labels_id WHERE l.name = ‘^i’ ORDER BY m._id DESC;"
The code like this works ->
sqlite3 /data/data/com.google.android.gm/databases/mailstore.MYEMAIL@gmail.com.db "SELECT fromAddress || '@|@' || dateSentMs || '@|@' || Subject || '@|@' || snippet FROM messages ORDER BY _id DESC LIMIT %GMAILcount;"
How can I get this to work?
The tables are formed like this
MESSAGE_LABELS 0|_id|INTEGER|0||1 1|labels_id|INTEGER|1||0 2|message_messageId|INTEGER|1||0 3|message_conversation|INTEGER|0||0
LABELS 0|_id|INTEGER|0||1 1|canonicalName|TEXT|0||0 2|name|TEXT|0||0 3|numConversations|TEXT|0||0 4|numUnreadConversations|TEXT|0||0 5|color|INTEGER|0|2147483647|0 6|systemLabel|INTEGER|0|0|0 7|systemLabelOrder|INTEGER|0|0|0 8|hidden|INTEGER|0|0|0 9|labelCountDisplayBehavior|INTEGER|0|0|0 10|labelSyncPolicy|INTEGER|0|0|0 11|visibility|TEXT|0||0 12|lastTouched|INTEGER|0|0|0 13|numUnseenConversations|INTEGER|0|0|0 14|lastMessageTimestamp|INTEGER|1|0|0
MESSAGES 0|_id|INTEGER|0||1 1|messageId|INTEGER|0||0 2|conversation|INTEGER|0||0 3|fromAddress|TEXT|0||0 4|toAddresses|TEXT|0||0 5|ccAddresses|TEXT|0||0 6|bccAddresses|TEXT|0||0 7|replyToAddresses|TEXT|0||0 8|dateSentMs|INTEGER|0||0 9|dateReceivedMs|INTEGER|0||0 10|subject|TEXT|0||0 11|snippet|TEXT|0||0 12|listInfo|TEXT|0||0 13|personalLevel|INTEGER|0||0 14|body|TEXT|0||0 15|bodyEmbedsExternalResources|INTEGER|0||0 16|joinedAttachmentInfos|STRING|0||0 17|synced|INTEGER|0||0 18|error|TEXT|0||0 19|clientCreated|INTEGER|0||0 20|refMessageId|INTEGER|0|0|0 21|forward|INTEGER|0|0|0 22|includeQuotedText|INTEGER|0|0|0 23|quoteStartPos|INTEGER|0|0|0 24|bodyCompressed|BLOB|0|NULL|0 25|customFromAddress|TEXT|0|NULL|0 26|queryId|INTEGER|0|1|0 27|spamDisplayedReasonType|INTEGER|0||0 28|deliveryChannel|INTEGER|0||0 29|referencesRfc822MessageIds|TEXT|0||0 30|showSendersFullEmailAddress|INTEGER|0||0 31|viaDomain|TEXT|0||0 32|showForgedFromMeWarning|INTEGER|0||0 33|refAdEventId|TEXT|0||0 34|permalink|TEXT|0||0 35|clipped|INTEGER|0|0|0