Skip to content

Instantly share code, notes, and snippets.

@speters
Last active January 16, 2020 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speters/486e54ca415d13808eda31851eab197a to your computer and use it in GitHub Desktop.
Save speters/486e54ca415d13808eda31851eab197a to your computer and use it in GitHub Desktop.
get email addresses from Android E-Mail app
/* with kind regards to http://www.samuelbosch.com/2018/02/split-into-rows-sqlite.html */
WITH RECURSIVE split(predictorset_id, predictor_name, rest) AS (
SELECT _id, '', fromList || char(1) || toList || char(1) FROM Message WHERE _id
UNION ALL
SELECT predictorset_id,
substr(rest, 0, instr(rest, char(1))),
substr(rest, instr(rest, char(1))+1)
FROM split
WHERE rest <> '')
SELECT DISTINCT
CASE WHEN instr(predictor_name, char(2))
THEN substr(predictor_name, 0, instr(predictor_name, char(2)))
ELSE predictor_name END
as email,
substr(predictor_name, instr(predictor_name, char(2))+1) as name
FROM split
WHERE predictor_name <> ''
UNION
SELECT accountAddress as email,
accountName as name
FROM EmailAddressCache
ORDER BY email;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment