我在Tasker(Android)中运行一个shell脚本来查询我的电子邮件,但它总是不返回任何内容。
sqlite3的 /data/data/com.google.android.gm/databases/mailstore.MYEMAIL@gmail.com.db “SELECT fromAddress ||'@ | @'|| dateSentMs ||'@ | @'|| Subject || '@ | @'||片段FROM消息m LEFT JOIN message_labels ml ON m._id = ml.message_messageId JOIN标签l ON l._id = ml.labels_id WHERE l.name ='^ i'ORDER BY m._id DESC;“
这样的代码有效 - >
sqlite3的 /data/data/com.google.android.gm/databases/mailstore.MYEMAIL@gmail.com.db “SELECT fromAddress ||'@ | @'|| dateSentMs ||'@ | @'|| Subject || '@ | @'||片段来自消息ORDER BY _id DESC LIMIT%GMAILcount;“
我怎样才能让它发挥作用?
表格就是这样形成的
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 |隐藏| INTEGER | 0 | 0 | 0 9 | labelCountDisplayBehavior | INTEGER | 0 | 0 | 10 | labelSyncPolicy | INTEGER | 0 | 0 | 0 11 |可见性| 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 |对话| 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 |同步| INTEGER | 0 || 0 18 |错误| 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 |文| 0 || 0 30 | showSendersFullEmailAddress | INTEGER | 0 || 0 31 | viaDomain | TEXT | 0 || 0 32 | showForgedFromMeWarning | INTEGER | 0 || 0 33 | refAdEventId | TEXT | 0 || 0 34 |固定链接| TEXT | 0 || 0 35 | clipped | INTEGER | 0 | 0 | 0
答案 0 :(得分:0)
your query seems to be fine, so my bet is that joined tables return NULL
what _id
do you get when query SELECT * FROM labels WHERE name = '^i'
in my case, it's 1
and when I run:
SELECT * FROM message_labels WHERE labels_id=1
I get.... nothing :) so here is where your code might be failing too
p.s.
I do recommend installing SQLiteDebugger - it is a tremendous help when working on more complex queries
答案 1 :(得分:0)
sqlite3 /data/data/com.google.android.gm/databases/mailstore.YOUREMAIL@gmail.com.db" SELECT fromAddress || ' @ | @' || dateSentMs || ' @ | @' ||主题|| ' @ | @' ||片段FROM消息m LEFT JOIN message_labels ml ON m.messageId = ml.message_messageId JOIN标签l ON l._id = ml.labels_id WHERE l.name =' ^ i' ORDER BY m._id;"
是正确的吗? m.messageId而不仅仅是_id