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');
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?