SQLite

93 readers
1 users here now

A community for SQLite, a small fast SQL database engine. https://www.sqlite.org/index.html

founded 9 months ago
MODERATORS
1
2
3
6
SQLite Transactions (reorchestrate.com)
submitted 4 months ago by mac to c/sqlite
4
0
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/sqlite
 
 

Hello, when I use following sqlite3 commands, it returns error "cannot commit - no transaction is active" somewhere near the line "WHERE user IN (".... So I wanted to ask what to replace with what in order not to produce said error. I am not a developer and the ChatGPT (1, 2) is unable to provide working code. Can you please help?

said commands:

-- Start a transaction
BEGIN TRANSACTION;

-- Insert missing user_permission_overrides rows
INSERT INTO user_permission_overrides (room, user, write)
SELECT DISTINCT ru.room, u.id, TRUE
FROM room_users ru
JOIN users u ON ru.user = u.id
LEFT JOIN user_permission_overrides upo ON u.id = upo.user AND ru.room = upo.room
WHERE u.created < strftime('%s', '2024-07-02 00:49:26')
AND upo.user IS NULL;

-- Update existing user_permission_overrides rows
UPDATE user_permission_overrides
SET write = TRUE
WHERE user IN (
    SELECT id
    FROM users
    WHERE created < strftime('%s', '2024-07-02 00:49:26')
);

-- Commit the transaction
 COMMIT;

 END;

list of tables, schema, pragma I have pasted here please.

5
6
16
submitted 6 months ago by mac to c/sqlite
7
10
submitted 7 months ago by canpolat to c/sqlite
8
18
submitted 8 months ago by mac to c/sqlite
9
5
SQLite Release 3.45.2 (www.sqlite.org)
submitted 8 months ago by mac to c/sqlite
10
11
9
SQLite Release 3.45.1 (www.sqlite.org)
submitted 9 months ago by mac to c/sqlite