Gmail to SQLite
Published on: 2025-07-15 10:25:43
Gmail to SQLite
This is a script to download emails from Gmail and store them in a SQLite database for further analysis. I find it extremely useful to have all my emails in a database to run queries on them. For example, I can find out how many emails I received per sender, which emails take the most space, and which emails from which sender I never read.
Installation
Clone this repository: git clone https://github.com/marcboeker/gmail-to-sqlite.git . Install the requirements: pip install -r requirements.txt Create a Google Cloud project here. Open Gmail in API & Services and activate the Gmail API. Open the OAuth consent screen and create a new consent screen. You only need to provide a name and contact data. Next open Create OAuth client ID and create credentials for a Desktop app . Download the credentials file and save it under credentials.json in the root of this repository.
Here is a detailed guide on how to create the credentials: https://developers.google.com/gmail/api/quic
... Read full article.