Button guide
Let non-technical colleagues run a SQL report with their own date range a form that runs your query script
Put the query inside a short Python script that takes the date range and region as command-line arguments, and publish it on Button (https://button.bitgate.dev) as a web form your colleagues can run in their browser. The script runs on your own computer using your existing database setup and writes out a CSV or Excel file up to 25 MB (up to 8 files and 100 MB total per run) for them to download. You can publish 1 tool for up to 3 colleagues on the $0 Free plan, or up to 50 tools for 250 people on Pro for $15/month.
Wrap the query in a Python script
If you already have the SQL query sitting in a file or a scratchpad, the only work on the code side is swapping out the dates and region you normally edit by hand and taking them from the command line with argparse. Take the output folder as an argument too, so the script knows where to drop the finished CSV or Excel file.
Always pass the user's inputs into the query using your database driver's bind parameters, never with Python string formatting (f"...", .format(), or %). Button passes each form value to your program as its own separate argument with no shell in the middle, and it rejects any value that starts with -, which handles command-line safety for you, but once those strings are inside your Python script, your database driver still needs bind parameters so a value never gets parsed as SQL.
import argparse
import configparser
import os
from pathlib import Path
import pandas as pd
import psycopg2
parser = argparse.ArgumentParser()
parser.add_argument("--start-date", required=True)
parser.add_argument("--end-date", required=True)
parser.add_argument("--region", required=True)
parser.add_argument("--format", choices=["csv", "xlsx"], default="csv")
parser.add_argument("--out-dir", required=True)
args = parser.parse_args()
config = configparser.ConfigParser()
config.read(Path(__file__).with_name("db.ini"))
query = """
SELECT order_id, created_at, region, total_amount
FROM orders
WHERE created_at >= %s
AND created_at < %s
AND region = %s
ORDER BY created_at
"""
conn = psycopg2.connect(**config["database"])
df = pd.read_sql_query(query, conn, params=(args.start_date, args.end_date, args.region))
conn.close()
if args.format == "xlsx":
df.to_excel(os.path.join(args.out_dir, "report.xlsx"), index=False)
else:
df.to_csv(os.path.join(args.out_dir, "report.csv"), index=False)
Keep the connection settings in a db.ini file next to the script (a [database] section with host, dbname, user and password), and give the report a read-only database user. Test it once in your terminal to make sure it writes the file cleanly into the folder you pass to --out-dir. And if you prefer R (commandArgs()), Node, PowerShell (param()), a shell script ($1 and $2), or a compiled binary, those all work the same way.
Turn the script into a web form on Button
Once the script runs from the command line, you hook it up to a form.
- Sign in at https://button.bitgate.dev.
- Install the Button runner on your computer (macOS, Linux, or Windows) by running the one-line command the site shows you - it's a
curlcommand on macOS and Linux, or PowerShell on Windows. - Open the local setup page and pick your Python script.
- Set up the form inputs that map to your script's arguments: two text fields for the start date and end date, a choice field for the region, and another choice field if you want them picking between CSV and Excel. (Button supports text, number, yes/no, choice, and file inputs. Fixed flags like
--start-dateand--regionare part of the command you approve on your machine, so your colleagues only supply the values for the form fields.) - Approve the command on your computer and publish the tool. Button pins the exact command you approved by hash, and the runner will only ever execute that approved command.
- Invite the colleagues who need the report.
When your colleagues open the link from their invite email, they sign in with Google or a one-time email code, fill in the dates and region, press Run, and download the CSV or Excel file when it finishes. They don't install anything and they never pay.
The job runs on your computer, not in Button's cloud, while Button's servers relay the form values and output files between your colleague's browser and your machine. Because it runs on your computer, your computer has to be on and online when somebody runs the report; the tool page shows Ready, Busy, or Offline so they can see right away if it's available, and your computer handles one run at a time. Every run is logged with who ran it and when, and if you change the tool, people have to confirm the new version before running it. You can also set someone's access to expire or revoke it whenever you want.
When to use Metabase or Redash instead
If people want to explore the data on their own, filter tables, click around dashboards, or write their own queries, don't build a form around a single script. Set up a BI or query tool instead. Metabase and Redash are both built for that, whereas Button is for one fixed report that needs to run on your machine with your database access.
| Tool | Best for | Where it runs | Pricing |
|---|---|---|---|
| Button | One fixed report script that runs with your local setup and database access | Your own computer (macOS, Linux, Windows); form and file relay via Button's servers | Free: $0 (1 tool, 3 people, 100 runs/mo, 1 GB transfer/mo). Pro: $15/mo or $144/yr ($12/mo) for 50 tools, 250 people, 5,000 runs/mo, 50 GB transfer/mo |
| Metabase | Dashboards and self-serve data exploration | Self-hosted, or Metabase Cloud | Open-source edition is free to self-host. Cloud Starter is $100/mo ($90/mo billed yearly) with 5 users, plus $6 per extra user |
| Redash | Shared SQL queries and dashboards | Self-hosted | Open source, free to self-host |
With Metabase or Redash, you connect the tool to your database once and let the team browse from there. Button fits when you can't or don't want to stand up a shared server with direct database access, or when the report is already a local Python or R script and you just want three people in operations to stop messaging you every Monday for the same CSV.
Limits to keep in mind
A single run on Button can take up to 30 minutes, log up to 1 MB of output, and produce up to 8 files (up to 25 MB per file, 100 MB total per run). If your query dumps a 200 MB CSV, it won't fit; filter it down in SQL or aggregate before writing the file. Button deletes run inputs from its servers 24 hours after a run ends, and deletes outputs after 7 days.
Every plan gives you one computer (runner) per workspace. Pairing a new computer replaces the previous one. On the pricing side, "people" counts the distinct colleagues you've invited (you don't count toward the limit), while the monthly run count includes your own test runs. If you ever downgrade from Pro to Free, nothing gets deleted.
FAQ
Does my computer have to stay on for colleagues to run the report?
Yes, jobs run on your computer, so it needs to be turned on and connected to the internet. The tool page shows Ready, Busy, or Offline so colleagues know whether your machine is available before they hit Run.
Can someone pass a malicious flag or SQL command through the form?
Button runs the exact command you approved without a shell, passes each form value as a separate argument, and blocks values starting with -. Inside your script, you still need to use bind parameters in your SQL query instead of string formatting so the database treats those arguments strictly as values.
How big can the exported CSV or Excel file be?
Each file can be up to 25 MB, and a single run can produce up to 8 files totaling 100 MB. Output files stay available to download for 7 days after the run finishes, and inputs are deleted after 24 hours.
Do the colleagues who run the report need a paid Button account?
No, recipients never pay and don't install anything. They open the link from their invite email and sign in with Google or a one-time email code.
Can two people run the report at the same time?
Your computer executes one run at a time, for up to 30 minutes per run. While a report is running, the tool page shows Busy until it finishes.
Last updated
Put your script behind a form
Button turns a script on your computer into a web form. Colleagues sign in, fill it in, press Run and download the results. Free for 1 tool and 3 people.