跳转到主要内容

创建包含您的Google日历数据的SQLite数据库

项目描述

google-calendar-to-sqlite

PyPI Changelog Tests License

创建包含您从Google日历数据的SQLite数据库

这允许您使用SQL分析Google日历数据,使用Datasette或SQLite命令行工具或任何其他SQLite数据库浏览软件。

安装

使用pip安装此工具

pip install google-calendar-to-sqlite

快速入门

运行以下命令通过Google日历进行认证

google-calendar-to-sqlite auth

现在使用以下命令创建包含您的日历数据的SQLite数据库

google-calendar-to-sqlite events calendar.db your-email@gmail.com

您可以传递一个或多个日历ID - 这些看起来像电子邮件地址。您的Gmail主账户对应于您的个人日历。

如果您不传递任何日历ID,则将从所有日历中获取事件

google-calendar-to-sqlite events calendar.db

此命令将创建一个具有每个事件的行的events表。重复事件将只出现一次,其重复规则存储在recurrence列中。

您可以使用Datasette探索生成的数据库

$ pip install datasette
$ datasette calendar.db
INFO:     Started server process [24661]
INFO:     Uvicorn running on http://127.0.0.1:8001

查看日历列表

您可以使用以下方法查看日历列表

google-calendar-to-sqlite calendars

这将输出它们的ID和名称到终端

$ google-calendar-to-sqlite calendars             
Work: 2mcbt9bcthbvsm21j4rp4drhs8@group.calendar.google.com
Simon Stanford Classes: tsblj5a6il733cd92kv08crkrg@group.calendar.google.com
Pillar Point Stewards: tqhbk05br2h57kcd0gebbt9nmoq3iebt@import.calendar.google.com
Holidays in United States: en.usa#holiday@group.v.calendar.google.com

如果您添加数据库文件名,则将使用该列表填充详细的calendars

google-calendar-to-sqlite calendars calendars.db

该数据库中的事件将具有外键回它们所属的日历。

认证

:warning: 此应用程序尚未经过Google验证 - 您可能发现您无法认证,直到验证完成。

您可以通过创建自己的OAuth客户端ID密钥并使用auth命令通过--google-client-id--google-client-secret将其传递来解决这个问题。

首先,使用auth命令通过Google日历进行认证

$ google-calendar-to-sqlite auth
Visit the following URL to authenticate with Google Calendar

https://#/o/oauth2/v2/auth?...

Then return here and paste in the resulting code:
Paste code here: 

点击链接,使用Google日历登录,然后将生成的代码粘贴回工具中。

这将在当前目录下名为auth.json的文件中保存一个认证令牌。

要指定不同位置存储该文件,请使用--auth选项。

google-calendar-to-sqlite auth --auth ~/google-calendar-auth.json

完整--help

Usage: google-calendar-to-sqlite auth [OPTIONS]

  Authenticate user and save credentials

Options:
  -a, --auth FILE              Path to save token, defaults to auth.json
  --google-client-id TEXT      Custom Google client ID
  --google-client-secret TEXT  Custom Google client secret
  --scope TEXT                 Custom token scope
  --help                       Show this message and exit.

要撤销存储在auth.json中的令牌,以便将来无法使用该令牌访问Google日历,请运行revoke命令。

google-calendar-to-sqlite revoke

或者如果您的令牌存储在其他位置

google-calendar-to-sqlite revoke -a ~/google-calendar-auth.json

您需要使用该工具中的auth命令获取新的令牌,以便继续使用此工具。

数据库模式

此工具创建的数据库具有以下模式

CREATE TABLE [calendars] (
   [id] TEXT PRIMARY KEY,
   [name] TEXT,
   [description] TEXT,
   [kind] TEXT,
   [etag] TEXT,
   [summary] TEXT,
   [timeZone] TEXT,
   [colorId] TEXT,
   [backgroundColor] TEXT,
   [foregroundColor] TEXT,
   [accessRole] TEXT,
   [defaultReminders] TEXT,
   [conferenceProperties] TEXT,
   [location] TEXT,
   [selected] INTEGER,
   [summaryOverride] TEXT,
   [notificationSettings] TEXT,
   [primary] INTEGER
);
CREATE TABLE [events] (
   [id] TEXT PRIMARY KEY,
   [summary] TEXT,
   [location] TEXT,
   [start_dateTime] TEXT,
   [end_dateTime] TEXT,
   [description] TEXT,
   [calendar_id] TEXT REFERENCES [calendars]([id]),
   [kind] TEXT,
   [etag] TEXT,
   [status] TEXT,
   [htmlLink] TEXT,
   [created] TEXT,
   [updated] TEXT,
   [creator] TEXT,
   [organizer] TEXT,
   [iCalUID] TEXT,
   [sequence] INTEGER,
   [reminders] TEXT,
   [eventType] TEXT,
   [attendees] TEXT,
   [recurringEventId] TEXT,
   [originalStartTime] TEXT,
   [start_date] TEXT,
   [end_date] TEXT,
   [transparency] TEXT,
   [start_timeZone] TEXT,
   [end_timeZone] TEXT,
   [recurrence] TEXT,
   [guestsCanInviteOthers] INTEGER,
   [extendedProperties] TEXT,
   [colorId] TEXT,
   [hangoutLink] TEXT,
   [conferenceData] TEXT,
   [visibility] TEXT,
   [privateCopy] INTEGER,
   [guestsCanSeeOtherGuests] INTEGER,
   [attachments] TEXT
);

隐私政策

此工具请求访问您的Google日历账户,以从您的日历中检索事件并将它们存储在您的计算机上的本地SQLite数据库文件中。

用于访问您的账户的凭据存储在您的计算机上的auth.json文件中。从Google日历检索的数据也仅存储在您的个人计算机上。

在此工具的开发者任何时候都不会获取您的任何数据。

开发

要为此工具做出贡献,首先检出代码。然后创建一个新的虚拟环境

cd google-calendar-to-sqlite
python -m venv venv
source venv/bin/activate

或者如果您正在使用pipenv

pipenv shell

现在安装依赖项和测试依赖项

pip install -e '.[test]'

要运行测试

pytest

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

google-calendar-to-sqlite-0.1a0.tar.gz (11.5 kB 查看哈希)

上传时间:

构建分发

google_calendar_to_sqlite-0.1a0-py3-none-any.whl (12.5 kB 查看哈希)

上传时间: Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面