npx wrangler d1 execute my-db --command "SELECT * FROM users LIMIT 10"

Category: Cloudflare

npx wrangler d1 execute my-db --command "SELECT * FROM users LIMIT 10"

Run SQL against a D1 database

Executes the quoted SQL against the local D1 database by default, printing the rows as a table. You must supply either --command or --file. Add --remote to hit the production database, and --json to get results as JSON instead of a table.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.