Skip to content

Instantly share code, notes, and snippets.

@mizchi
Last active September 4, 2023 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/e26727dd195e175232e1153071650b26 to your computer and use it in GitHub Desktop.
Save mizchi/e26727dd195e175232e1153071650b26 to your computer and use it in GitHub Desktop.
$ cat test.sql
select 1;
-- comment;
select 2;⏎
$ env WRANGLER_LOG=debug pnpm wrangler d1 execute mydb2 --file test.sql --batch-size 1
--------------------
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
🚧 To give feedback, visit https://discord.gg/cloudflaredev
--------------------
πŸŒ€ Mapping SQL input into an array of statements
πŸŒ€ Parsing 2 statements
πŸŒ€ We are sending 2 batch(es) to D1 (limited to 1 statements per batch. Use --batch-size to override.)
βœ” ⚠️ Too much SQL to send at once, this execution will be sent as 2 batches.
ℹ️ Each batch is sent individually and may leave your DB in an unexpected state if a later batch fails.
⚠️ Make sure you have a recent backup. Ok to proceed? … yes
πŸŒ€ Let's go
Retrieving cached values for account from node_modules/.cache/wrangler
πŸŒ€ Executing on mydb2 (837018aa-cde8-49ce-ac2a-68225f45dea8):
select 1
-- START CF API REQUEST: POST https://api.cloudflare.com/client/v4/accounts/f90b16619da21adbec058f5c09b1de53/d1/database/837018aa-cde8-49ce-ac2a-68225f45dea8/query
HEADERS: {
"Content-Type": "application/json",
"User-Agent": "wrangler/3.6.0"
}
INIT: {
"method": "POST",
"headers": {
"Content-Type": "application/json",
"User-Agent": "wrangler/3.6.0"
},
"body": "{\"sql\":\"select 1\"}"
}
-- END CF API REQUEST
-- START CF API RESPONSE: OK 200
HEADERS: {
"cf-cache-status": "DYNAMIC",
"cf-ray": "801643869a2f20a1-NRT",
"connection": "keep-alive",
"content-encoding": "gzip",
"content-type": "application/json; charset=UTF-8",
"date": "Mon, 04 Sep 2023 12:33:57 GMT",
"server": "cloudflare",
"set-cookie": "__cfruid=<masked> -1693830837; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None",
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"x-envoy-upstream-service-time": "495"
}
RESPONSE: {
"result": [
{
"results": [
{
"1": 1
}
],
"success": true,
"meta": {
"served_by": "v3-prod",
"duration": 0.20614099875092504,
"changes": 0,
"last_row_id": 0,
"changed_db": false,
"size_after": 36864,
"rows_read": 0,
"rows_written": 0
}
}
],
"success": true,
"errors": [],
"messages": []
}
-- END CF API RESPONSE
🚣 Executed 1 commands in 0.20614099875092504ms
-- comment;
select 2
-- START CF API REQUEST: POST https://api.cloudflare.com/client/v4/accounts/f90b16619da21adbec058f5c09b1de53/d1/database/837018aa-cde8-49ce-ac2a-68225f45dea8/query
HEADERS: {
"Content-Type": "application/json",
"User-Agent": "wrangler/3.6.0"
}
INIT: {
"method": "POST",
"headers": {
"Content-Type": "application/json",
"User-Agent": "wrangler/3.6.0"
},
"body": "{\"sql\":\"-- comment;\\nselect 2\"}"
}
-- END CF API REQUEST
-- START CF API RESPONSE: Internal Server Error 500
HEADERS: {
"cf-cache-status": "DYNAMIC",
"cf-ray": "8016438bde7020a1-NRT",
"connection": "keep-alive",
"content-encoding": "gzip",
"content-type": "application/json; charset=UTF-8",
"date": "Mon, 04 Sep 2023 12:33:57 GMT",
"server": "cloudflare",
"set-cookie": "__cfruid=<masked>; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None",
"transfer-encoding": "chunked",
"vary": "Accept-Encoding",
"x-envoy-upstream-service-time": "421"
}
RESPONSE: {
"result": [],
"success": false,
"errors": [
{
"code": 7500,
"message": "SQL code did not contain a statement."
}
],
"messages": []
}
-- END CF API RESPONSE
✘ [ERROR] A request to the Cloudflare API (/accounts/f90b16619da21adbec058f5c09b1de53/d1/database/837018aa-cde8-49ce-ac2a-68225f45dea8/query) failed.
SQL code did not contain a statement. [code: 7500]
If you think this is a bug, please open an issue at:
https://github.com/cloudflare/workers-sdk/issues/new/choose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment