Closed Tombarr closed 1 year ago
I've been able to successfully run commands, but it still seems like executing CREATE
or INSERT
statements are no-ops. For instance, I'm running the much simpler command:
WRANGLER_LOG=debug npx wrangler d1 execute kaios-apps-dev --file ./test.sql
test.sql
BEGIN TRANSACTION;
CREATE TABLE apps (
id VARCHAR(20) NOT NULL PRIMARY KEY CHECK (length(id) <= 20),
name VARCHAR NOT NULL CHECK (length(name) > 0),
summary VARCHAR,
display VARCHAR,
description VARCHAR,
subtitle VARCHAR,
version VARCHAR NOT NULL,
bundle_id VARCHAR,
google_bundle_id VARCHAR,
developer VARCHAR,
developer_url VARCHAR,
manifest_url VARCHAR,
jio_manifest_url VARCHAR,
v3_manifest_url VARCHAR,
thumbnail_url VARCHAR,
background_url VARCHAR,
default_locale VARCHAR,
screenshots VARCHAR,
theme VARCHAR(7) CHECK (length(theme) <= 7),
category VARCHAR,
type VARCHAR(10) CHECK (length(type) <= 10),
size INTEGER CHECK (size IS NULL OR size >= 0),
packaged_size INTEGER CHECK (packaged_size IS NULL OR packaged_size >= 0),
paid BOOLEAN CHECK (paid IN (NULL, 0, 1)),
priority INTEGER CHECK (priority >= 0 OR priority IS NULL),
release_date INTEGER NOT NULL CHECK (release_date >= 0),
ad BOOLEAN CHECK (ad IN (NULL, 0, 1)),
hidden BOOLEAN CHECK (hidden IN (NULL, 0, 1)),
silent BOOLEAN CHECK (silent IN (NULL, 0, 1)),
cursor BOOLEAN CHECK (cursor IN (NULL, 0, 1)),
fullscreen BOOLEAN check (fullscreen IN (NULL, 0, 1)),
package_path VARCHAR,
origin VARCHAR,
short_name VARCHAR,
start_url VARCHAR,
activities VARCHAR,
chrome VARCHAR,
permissions VARCHAR,
messages VARCHAR,
dependencies VARCHAR
);
INSERT INTO apps VALUES('velPJ_36DVeV4P1e72ma','jiogames',NULL,'JioGames','Have fun by playing the exciting games','Have fun playing exciting games!','2.6.0.7',NULL,NULL,'Jio','http://www.jio.com',NULL,'https://api.kai.jiophone.net/v2.0/apps/manifest/velPJ_36DVeV4P1e72ma',NULL,'https://storage.kai.jiophone.net/v2.0/files/app/I/P3SpFVYpzWUPv4T8WiCtDqYHcDz_D-EDCXOYKK/ICON_IMAGE.png','https://storage.kai.jiophone.net/v2.0/files/app/I/Y6vhEjmMECVEZjb0oGAZw7pYeF2v7Tx_RJQrki/BG_IMAGE.png','en-US',NULL,'#63B208','Games','privileged',5072597,1572644,0,0,1644844359448,NULL,0,0,NULL,NULL,'https://storage.kai.jiophone.net/v2.0/files/app/s/gazFr5CRlWn3QBe7bnoRNtAWV7K21UjyAY8E6w/2.6.0.7_APP_ZIP_FILE.zip',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
CREATE TABLE locales (
id VARCHAR(20) NOT NULL CHECK (length(id) <= 20),
language VARCHAR NOT NULL,
name VARCHAR NOT NULL,
subtitle VARCHAR,
description VARCHAR
);
INSERT INTO locales VALUES('velPJ_36DVeV4P1e72ma','as-IN','เฆเฆฟเฆ
โเฆเงเฆฎเงเฆ','Play highly engaging games','Rich collection of games across genres. Create top scores and get featured in leaderboards');
COMMIT;
In this example, I've removed CHECK
constraints and Foreign Keys, and reduced ~5k INSERT
commands to two rows. There's a warning at the top of the console output:
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
But execution continues
๐ Mapping SQL input into an array of statements
๐ Parsing 6 statements
Retrieving cached values for account from node_modules/.cache/wrangler
...
๐ Executing on kaios-apps-dev (e6f3ef99-d12b-4315-ac90-8bade2796835):
-- START CF API REQUEST: POST https://api.cloudflare.com/client/v4/accounts/9c8d0030925ba2d451646f8b9d581d4e/d1/database/e6f3ef99-d12b-4315-ac90-8bade2796835/query
..
RESPONSE: {
"result": [
{
"results": [],
"success": true,
"meta": {
"duration": 0.32485300302505493,
"last_row_id": null,
"changes": null,
"served_by": "primary-e6f3ef99-d12b-4315-ac90-8bade2796835.db3",
"internal_stats": null
}
}
],
"result_info": null,
"success": true,
"errors": [],
"messages": []
}
-- END CF API RESPONSE
๐ฃ Executed 1 command in 0.32485300302505493ms
But when I check the D1 dashboard in on the Cloudflare website, it shows "0 tables," and when I query for the result, nothing shows up.
npx wrangler d1 execute kaios-apps-dev --command "SELECT * FROM sqlite_schema"
Returns the following
๐ Mapping SQL input into an array of statements
๐ Parsing 1 statements
๐ Executing on kaios-apps-dev (e6f3ef99-d12b-4315-ac90-8bade2796835):
๐ฃ Executed 1 command in 0.20165200531482697ms
โโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ type โ name โ tbl_name โ rootpage โ sql โ
โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ table โ d1_kv โ d1_kv โ 2 โ CREATE TABLE d1_kv (key TEXT PRIMARY KEY, value TEXT NOT NULL) โ
โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ index โ sqlite_autoindex_d1_kv_1 โ d1_kv โ 3 โ โ
โโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Update (1/20/23): I originally thought the issue was related to character encodings, but I've been able to upload the database using d1 execute
in chunks of a few hundred rows per upload. It seems the WASM RuntimeError
happening in D1 core may be related to the number of INSERT
statements or the size of the file. For reference, the entire SQL file I tried uploading was ~3.7mb.
Thanks for flagging this. In an effort to remove stale issues so we can have better signal on current friction points, weโre closing out issues that have not been updated within the last 6 months. If this is still a problem, please feel free to open a new issue referencing this one. Please be sure to include an updated summary and any additional context and we will review. Thank you!
Which Cloudflare product(s) does this pertain to?
D1
What version of
Wrangler
are you using?2.7.1
What operating system are you using?
Mac M1 13.1
Describe the Bug
Wrangler D1 databases can be created but running
wrangler d1 execute "kaios-apps-dev" --file ./apps.sql
crashes.This is a sample row from the
apps.sql
file I am trying to upload.If I keep the transaction block, it hangs indefinitely at "๐ Mapping SQL input into an array of statements," and I have to terminate the node process. If I remove the transaction block, I get this crash:
OS: Mac Ventura 13.1 (M1) Node: v18.13.0 (also tested 16.16.0) npm: 8.19.3 (and 8.11.0 for Node 16 LTS) nvm: 0.39.0 wrangler: 2.7.1 (tested locally & globally on 2.6.1 & 2.5.0)