-
I want to expose accounting tables of GNUCash via web app. How should it be expressed? For a toy example, how should I update https://github.com/lovasoa/SQLpage/blob/main/examples/splitwise/index.sql so that with two sessions open, when one triggers insert from form, another updates bottom list. -- Simple form to create a shared expense account
SELECT 'form' as component,
'New shared expense account' as title,
'Create the shared expense account!' as validate;
SELECT 'Account Name' AS label,
'shared_expense_name' AS name;
-- Insert the shared expense account posted by the form into the database
INSERT INTO expense_group(name)
SELECT :shared_expense_name
WHERE :shared_expense_name IS NOT NULL;
-- List of shared expense accounts
-- (we put it after the insertion because we want to see new accounts right away when they are created)
SELECT 'list' as component;
SELECT name AS title,
'group.sql?id=' || id AS link
FROM expense_group; How should this be updated? And related follow up, can form send data without reloading page? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello ! Your best option if you want to get something running quickly is to create a separate sql file with 'shell-none' as component and to poll it regularly and insert the result in the web page using JavaScript. You can include your own js in your page using the javascript top level property of the shell component. If you want to avoid polling, then you can use postgres' LISTEN/NOTIFY system, where you do the NOTIFY from SQLPage and set up a third party server where you do the LISTEN and and the server sent events. |
Beta Was this translation helpful? Give feedback.
Hello !
Currently SQLPage supports neither server sent events nor websockets.
Your best option if you want to get something running quickly is to create a separate sql file with 'shell-none' as component and to poll it regularly and insert the result in the web page using JavaScript. You can include your own js in your page using the javascript top level property of the shell component.
You can also customize the form submission button behavior in your own JavaScript, but there is no built-in feature in SQLPage to help you with that.
If you want to avoid polling, then you can use postgres' LISTEN/NOTIFY system, where you do the NOTIFY from SQLPage and set up a third party server where you…