We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 332b5f8 commit f5f39b4Copy full SHA for f5f39b4
notifications.py
@@ -5,3 +5,24 @@ def handle_connect():
5
@socketio.on('disconnect')
6
def handle_disconnect():
7
print('Client disconnected')
8
+
9
+@socketio.on('subscribe')
10
+def handle_subscribe():
11
+ conn.cursor().execute('LISTEN user_changed')
12
13
14
+CREATE OR REPLACE FUNCTION notify_user_changed()
15
+RETURNS trigger AS
16
+$$
17
+BEGIN
18
+ PERFORM pg_notify('user_changed', NEW.id::text);
19
+ RETURN NEW;
20
+END;
21
+$$ LANGUAGE plpgsql;
22
23
+CREATE TRIGGER user_changed_trigger
24
+AFTER INSERT OR UPDATE OR DELETE ON users
25
+FOR EACH ROW
26
+EXECUTE PROCEDURE notify_user_changed();
27
28
0 commit comments