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

199
Visualizações
How to write a COPY TO query with node js

I would like to be able to export a PostgreSQL table as a csv file with node.js and have it appear in the user's downloads - like this:

enter image description here

When I press a button ('export to csv') function is called so that a SQL request is sent to the server.

However I'm not sure which query to use to meet my need.

I first tested these queries with the command line editor SQL (shell):

enter image description here

and

enter image description here

Here are some of the queries I have tried

async function exportDatabase(req, res){
return db.any('COPY tag_7z8eq73 TO STDOUT')
.then(rows => {
        res.json(rows)
    })
    .catch(error => {
        console.log(error)
    });   
}

or this query, but I can't use quotes like this ''

enter image description here

These others "more classic" queries works perfectly.

enter image description here

Do you know what query I can write in my function to meet my need ?

about 4 years ago · Juan Pablo Isaza
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