Reputation: 3149
In a long-running management command I'd like to have two connections to the same DB. One connection will hold a transaction to lock a certain row (select for update
) and the other connection will record some processing info. If the process crashes, a new run of the management command can use the processing info to skip/simplify some processing steps, hence the need to record it in a different connection.
How do I go about creating a 2nd connection in the same thread? My first thought was to add a default2
entry to DATABASES
with the same connection info as default
and use .using("default2")
in one of the queries, but wasn't sure if that would cause issues in Django
Upvotes: 1
Views: 41