Back to Blog

Google Sheets just got more powerful with SQL queries

Simon Willison just dropped a brilliant technique that makes Google Sheets infinitely more useful: running SQL queries directly in your spreadsheets.

He's documented three ways to pull data from Datasette (a tool for publishing databases) straight into Google Sheets: using the built-in importdata() function, creating custom named functions, or writing Google Apps Scripts for more complex authentication needs.

This is huge for small businesses drowning in data scattered across different systems. Most SMEs we work with have their customer data in one place, sales figures in another, and inventory somewhere else entirely. They spend hours copying, pasting, and manually updating spreadsheets that should update themselves.

What Willison's shown here is a path to automatic data updates without the complexity of traditional business intelligence tools. Instead of paying thousands for enterprise software or hiring a data analyst, you can now write simple SQL queries that refresh your Google Sheets automatically. Your sales dashboard updates itself. Your inventory reports stay current. Your financial summaries pull live data.

We've seen this pattern work brilliantly with clients who have basic databases but need their data in spreadsheet format for analysis or reporting. The importdata() function is surprisingly powerful, and most people have no idea it exists. Add SQL capability through Datasette, and suddenly your Google Sheet becomes a proper reporting tool.

The Google Apps Script option is particularly clever for businesses with API keys or authentication requirements. You're not limited to public data anymore. Your CRM, your e-commerce platform, your accounting software, if it has an API and you can structure the data properly, you can pull it directly into your spreadsheets.

This approach sidesteps the usual problems with data integration projects. No complex ETL processes, no expensive middleware, no vendor lock-in. Just your existing Google Sheets talking directly to your data sources using SQL queries you can understand and modify.

The real beauty is in the maintenance. When your data structure changes, you update the SQL query, not a complex integration pipeline. When you need different reports, you create new sheets with new queries. It's simple, transparent, and you stay in control.

Try this: identify one manual data task you do regularly in spreadsheets. If that data comes from a database or API, see if you can restructure it with Datasette and pull it directly into Google Sheets. Start small, but start today. Your future self will thank you when those monthly reports update themselves.