Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
Descargar datos de postgres a s3

Estoy tratando de descargar una tabla de datos de la base de datos de Postgres en Amazon S3.

Soy consciente de que redshift tiene la opción de descargar en s3: dado que redshift es una base de datos de postgres, intenté usar el mismo comando en mi base de datos de postgres pero no tuve éxito.

¿Puede alguien ayudarme a descargar datos de tablas de postgres a s3 periódicamente?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Redshift se basa en un clon de PostgreSQL pero no hay una correspondencia de características 1-1. Si desea cargar datos de una base de datos PostgreSQL a Redshift, a través de S3, debe:

  1. Descargue sus datos de PostgreSQL a un archivo CSV. Para hacer eso, use el comando copiar de psql. Ver también esta pregunta aquí .
  2. Copie el archivo CSV en S3. Hay diferentes formas de hacerlo, pero consulte la documentación aquí .
  3. Use el comando COPY para cargar los datos de S3 a Redshift
about 4 years ago · Santiago Trujillo Report

0

En Redshift puedes crear una tabla para recibir los datos:

CREATE TABLE redshift_schema.redshift_table (...);

Luego, cree un contenedor de datos externos, un servidor y un fantasma virtual de la tabla en PostgreSQL RDS:

 CREATE EXTENSION redshift_fdw; ----optional --CREATE FOREIGN DATA WRAPPER redshift_fdw --HANDLER postgres_fdw_handler --VALIDATOR postgres_fdw_validator --OPTIONS (); CREATE SERVER redshift_server_mydb FOREIGN DATA WRAPPER redshift_fdw OPTIONS (dbname 'mydb', port '5439', connect_timeout '200000', host 'myhost.redshift.amazonaws.com'); CREATE USER MAPPING FOR mypguser SERVER redshift_server_mydb OPTIONS (user 'myrsuser', password 'mypassword'); IMPORT FOREIGN SCHEMA redshift_schema LIMIT TO (redshift_table) FROM SERVER redshift_server_mydb INTO postgresql_schema;

Ahora en PostgreSQL puede (en una función si lo desea) cargar (seleccionar, insertar, actualizar, eliminar) la tabla Redshift de la tabla PostgreSQL (sin usar dblink):

 INSERT INTO postgresql_schema.redshift_table SELECT * FROM postgresql_schema.postgresql_table;

Ahora, cuando mira la tabla Redshift, todos los datos están allí y puede DESCARGAR la tabla en S3 según sea necesario.

about 4 years ago · Santiago Trujillo Report

0

Usé el siguiente fragmento de código para eso:

 UNLOAD ('SELECT * FROM my_table') TO 's3://my-bucket/path' credentials 'aws_access_key_id=*****;aws_secret_access_key=*****' parallel off delimiter ',' ALLOWOVERWRITE ADDQUOTES HEADER ESCAPE gzip;

Puedes consultar también los siguientes enlaces:

https://docs.aws.amazon.com/redshift/latest/dg/t_Unloading_tables.html https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD_command_examples.html

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!