I'm trying to run multiple SQL statements at once. - When running multiple multi-line queries via D1

I'm trying to run multiple SQL statements at once. - When running multiple multi-line queries via D1 REST API everything works. - When running multiple multi-line queries via env.DB.exec(), I get an error. It can only parse multiple queries if each query is only a single line. works via db.exec()
-- Migration number: 0000 2024-10-18T05:40:01.544Z
CREATE TABLE todos (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);
INSERT INTO hub_migrations (name) values ('0000_create-todos');
-- Migration number: 0000 2024-10-18T05:40:01.544Z
CREATE TABLE todos (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);
INSERT INTO hub_migrations (name) values ('0000_create-todos');
doesn't via db.exec()
-- Migration number: 0000 2024-10-18T05:40:01.544Z
CREATE TABLE todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
INSERT INTO hub_migrations (name) values ('0000_create-todos');
-- Migration number: 0000 2024-10-18T05:40:01.544Z
CREATE TABLE todos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
INSERT INTO hub_migrations (name) values ('0000_create-todos');
16 Replies
jLynx
jLynx•2mo ago
There seems to be an issue with functions or D1. All of a sudden our deployments have started failing with
Error: Failed to publish your Function. Got error: binding MYAPP_DB of type d1 failed to generate. Please try again later or contact support.
Error: Failed to publish your Function. Got error: binding MYAPP_DB of type d1 failed to generate. Please try again later or contact support.
https://discord.com/channels/595317990191398933/789155108529111069/1298399101263806477
Alexander
Alexander•2mo ago
Same here: binding DB of type d1 failed to generate. Please try again later or contact support. [code: 10021]
Baya
Baya•2mo ago
The same issue here too: DB binding is throwing error
jLynx
jLynx•2mo ago
Check the link above, support are onto it 🙂
Ramstik
Ramstik•2mo ago
D1 team is asking what endpoint/function you are trying to work with?
Romeu Palos
Romeu Palos•2mo ago
We are also seeing this error. We are trying to deploy the code using npx wrangler deploy Partial toml file
d1_databases = [
{ binding = "configs", database_name = "configs", database_id = "f1e42435-758a-4abf-842d-2303131a96a1" },
]
d1_databases = [
{ binding = "configs", database_name = "configs", database_id = "f1e42435-758a-4abf-842d-2303131a96a1" },
]
Deployments fail 100% of the time. and running the worker remotely also does not work.
jLynx
jLynx•2mo ago
Not sure what you mean exactly here. Just a standard function that's linked to a d1 DB
Baya
Baya•2mo ago
I am seeing errors when binding in both Workers and Pages.
jLynx
jLynx•2mo ago
No description
jLynx
jLynx•2mo ago
This is on a pages deployment
jLynx
jLynx•2mo ago
Should probably put an update on https://www.cloudflarestatus.com/
Cloudflare Status
Welcome to Cloudflare's home for real-time and historical data on system performance.
Isaac McFadyen
Isaac McFadyen•2mo ago
Being actively worked on (status page I mean), thank you.
Ahz / Grimlor
Ahz / Grimlor•2mo ago
Drizzle works fine w d1.
ac
ac•2mo ago
Are there any plans to make it possible to have dynamic service bindings for D1? E.g. for single-tenant DB situations. It seems the only options to make those work right now are either fill wrangler.toml with a ton of service bindings, or use D1's REST API instead of service bindings. Would prefer to avoid both of those.... I found this related post, but mainly checking on whether this is still planned or if we need to go a different direction. The 10gb-per-DB limit means multitenant isn't a great plan with d1 either
Want results from more Discord servers?
Add your server