D
D
dibanshee2020-02-07 16:43:02
PostgreSQL
dibanshee, 2020-02-07 16:43:02

How to notify Django when a third-party application changes the database?

The crux of the issue is even a bit broader.
In general terms: there is a game server that works as a completely separate application and you can’t touch it, but all events on it are listened to by a "Listener" written in Python and saves events, or rather the results of games in the PostgreSQL database, Django 3.0 works as a front end, it is used this database, or rather information from it, but does not affect the tables associated with the game server. Users who visit the site see the results of the games and can help their "favorites" (a request and data are sent via the REST API to the game server). Those. it turns out a vicious circle - the Game Server, Listener listens to it, it affects the database, Django receives information from the database and indirectly affects the game server.
Listener saves to the database not with the help of django models, but directly. Of course, both Django and Listener use the same tables. Listener'a can be remade as you like, I thought I could somehow do all this through Celery. Dzhang uses Celery and Redis. I would be glad for any advice, otherwise I have already broken my head.
The Listener is convenient because no matter what information it "heard" on the game server, it changes everything in the database in a cycle and does not think about what it is, what table, etc. (all through variables).

The question itself is how to inform (notify) django that the database has changed by a third-party application, or perhaps advice on changing the schema (using Celery or Redis, maybe something else) in general?
PS Django notification I need to update data on the page through sockets, use Django signals).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-02-07
@dibanshee

If done well and correctly, then instead of Django, use some asynchronous framework to distribute changes to the queue broker, and use the database only as a repository of historical data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question