admin管理员组文章数量:1294341
I am working on a live dashboard which records changes in database and shows details related to it on the dashboard. Currently to get these live changes I am using a combination of triggers
, functions
and pg_notify
to generate notifications from postgres when some tables have CRUD operations in them.
All of this is working okay for now, but based on some suggestions I read online many people do not recommend to use triggers if it is possible, as they are hard to maintain and don't sit best with rest of our code base. So for this reason I want to try updating my trigger based approach with something which fits with my code better and easier to maintain. But I don't know what I can use instead of triggers to get live changes from database.
Most triggers in my database are just used to send postgres notification back to my backend where I am handling the changes directly, so if I can get the changes from the database without using triggers I think I can make it work, but I can't figure out how to do so.
Also, if you think that trigger based approach is better for my case then please inform me the same with why.
I am working on a live dashboard which records changes in database and shows details related to it on the dashboard. Currently to get these live changes I am using a combination of triggers
, functions
and pg_notify
to generate notifications from postgres when some tables have CRUD operations in them.
All of this is working okay for now, but based on some suggestions I read online many people do not recommend to use triggers if it is possible, as they are hard to maintain and don't sit best with rest of our code base. So for this reason I want to try updating my trigger based approach with something which fits with my code better and easier to maintain. But I don't know what I can use instead of triggers to get live changes from database.
Most triggers in my database are just used to send postgres notification back to my backend where I am handling the changes directly, so if I can get the changes from the database without using triggers I think I can make it work, but I can't figure out how to do so.
Also, if you think that trigger based approach is better for my case then please inform me the same with why.
Share Improve this question asked Feb 12 at 12:56 Tea TechTea Tech 1127 bronze badges 1- Online, people recommend a lot of things much of it nonsense. If you understand the process and it does what you want then you are way ahead of most Internet advice and you should consider staying with what you are doing. – Adrian Klaver Commented Feb 12 at 16:06
1 Answer
Reset to default 0You can use logical decoding to replicate data modifications. If you don't want to write your own logical decoding plugin, you can use existing solutions like wal2json or tools like Debezium that can use the built-in pgoutput
plugin.
Note that you will only get data modifications that way. Data definition statements (CREATE
, ALTER
and DROP
) are not captured.
本文标签: djangoGet table changes details without using triggers in postgresStack Overflow
版权声明:本文标题:django - Get table changes details without using triggers in postgres - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741598190a2387537.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论