4 ms·
How would you send an email when an event occurs (e.g. user registration) if your only backend logic is stored procedures?
by jcroll 10y ago
How would you send an email when an event occurs (e.g. user registration) if your only backend logic is stored procedures?
- ruslan_talpa 10y agoThe basic idea is that in db you generate events (lots of ways) and a custom script listens and reacts (sends the email) This page can give you an idea http://postgrest.com/examples/users/ http://postgrest.com/examples/users/ (somewhere in the middle of the article) But also note that there are tons of ways to extend the functionality of PostgreSQL. Here is a stackoverflow answer about this also http://stackoverflow.com/questions/12002662/how-can-i-send-email-from-postgresql-trigger http://stackoverflow.com/questions/12002662/how-can-i-send-e... it is even possible to do it directly in the db (but not recommended) http://brandolabs.com/pgmail http://brandolabs.com/pgmail
- jcroll 10y agoRight, then you still need a script listening to the event omitted from Posgrest. And if the scripts you are building are anything less than trivial it seems to me you are right back to Flask/Django/etc at all.
- ruslan_talpa 10y agoare you saying you need a framework to send an email or that somehow that script is not trivial? Maybe you are saying that it's not just email, you have to interact with some other services ... ok so it's a bit more complex and you go for a framework to handle that but your problem/task has just been reduced from building a complete REST api to reacting to a handful of events and taking appropriate actions. Postgrest is an executable that you start and you have an api right that second, it's not like it's another framework that you need to code against.