Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
How to defer a slow database operation with SQLAlchemy / Python

I've got a REST interface to a database, implemented in Python FastAPI + SQLAlchemy. I want to run some (relatively) costly operations on my data, such as calculating cryptographic hashes or signatures. My hope is to be able to:

  1. Perform the insert, so that all referential integrity is checked by the database.
  2. Return the REST response to the front-end (primary key of insert).
  3. Asynchronously calculate the costly hash/signature/whatever, and update into the DB (same table).

I'd prefer to have a cross-database solution, but it seems running a trigger on insert/update might be the way to go. If so, my target in production is PostgreSQL.

Does anyone have a suggested approach they'd favour?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I would try to separate the concerns.

  • Build a fast REST service that does items 1 and 2 (concern: consistent data persistence);
  • Create a scheduled job that does item 3 in the background using pgAgent or s/th similar (concern: data "decoration") or use a notify/listen setup to invoke a separate process.

Running a trigger would do the actions synchronously. As far as I understand this is not your intention.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda