simonw / google-drive-to-sqlite

Create a SQLite database containing metadata from Google Drive
https://datasette.io/tools/google-drive-to-sqlite
Apache License 2.0
152 stars 13 forks source link

`google-drive-to-sqlite get` command #3

Closed simonw closed 2 years ago

simonw commented 2 years ago

As seen in https://github.com/dogsheep/github-to-sqlite#making-authenticated-api-calls

simonw commented 2 years ago
% google-drive-to-sqlite get https://www.googleapis.com/drive/v3/files                   
Error: {
    "error": {
        "errors": [
            {
                "domain": "usageLimits",
                "reason": "accessNotConfigured",
                "message": "Access Not Configured. Drive API has not been used in project 148933860554 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=148933860554 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
                "extendedHelp": "https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=148933860554"
            }
        ],
        "code": 403,
        "message": "Access Not Configured. Drive API has not been used in project 148933860554 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=148933860554 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
    }
}

This showed me that I need to enable the Drive API: https://console.developers.google.com/apis/library/drive.googleapis.com?project=148933860554

I clicked the button.

simonw commented 2 years ago

OK, the prototype of this works really well:

google-drive-to-sqlite get https://www.googleapis.com/drive/v3/files --paginate files --nl --stop-after 100 \
  | sqlite-utils insert /tmp/f.db files - --nl --batch-size 5
simonw commented 2 years ago

Documentation: https://github.com/simonw/google-drive-to-sqlite/blob/da511c2f8eabc51175e974008ab94c32fc25aaa0/README.md#google-drive-to-sqlite-get-url