Skip to content

Instantly share code, notes, and snippets.

@blackary
Created January 28, 2023 12:32
Show Gist options
  • Save blackary/e2870697d93440bbb0c7b3696f354c36 to your computer and use it in GitHub Desktop.
Save blackary/e2870697d93440bbb0c7b3696f354c36 to your computer and use it in GitHub Desktop.
Getting access to a public Google sheet without any authentication setup
# First pip install 'shillelagh[all]'
from shillelagh.backends.apsw.db import connect
connection = connect(":memory:")
cursor = connection.cursor()
query = """
SELECT country, SUM(cnt)
FROM "https://docs.google.com/spreadsheets/d/1_rN3lm0R_bU3NemO0s9pbFkY5LQPcuy1pscv8ZXPtg8/edit#gid=0"
WHERE cnt > 0
GROUP BY country
"""
for row in connection.execute(query):
print(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment