Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

559
Vistas
How to run SQL query inside docker container and export results outside the container (.CSV)

In SQL server I tried to export a CSV file using below command

mysql> mysql -u username -p --host=rdshostname --port=rdsport --batch -e "select * from yourtable" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//' > export.csv

But no luck, So How I can export the above query result to CSV file?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The easiest approach is to run the query inside the container and then export the result to file on the host.

docker exec -it some-mysql bash -c 'mysql -h myhost -u root -pPassword --database sample --batch -e "select * from company"' 

This will print the query result, now redirect the resulting output to file on the host.

docker exec -it some-mysql bash -c 'mysql -h myhost -u root -pPassword --database sample --batch -e "select * from company"'  > sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//' > company.csv

then upload the file to s3 from the host

aws s3 cp company.csv s3://mybucket/rds/mydb/table.csv

company sample databse

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda