Created
June 24, 2019 23:32
-
-
Save hakanilter/0b79680b6953d496b59449e7b4d31346 to your computer and use it in GitHub Desktop.
Import CSV from S3 to Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.html#USER_PostgreSQL.S3Import.table_import_from_s3 | |
-- https://github.com/chimpler/postgres-aws-s3 | |
CREATE EXTENSION aws_s3 CASCADE; | |
DROP TABLE nyse; | |
CREATE TABLE nyse ( | |
exchange VARCHAR(50), | |
stock_symbol VARCHAR(50), | |
stock_date DATE, | |
stock_price_open DECIMAL, | |
stock_price_high DECIMAL, | |
stock_price_low DECIMAL, | |
stock_price_close DECIMAL, | |
stock_volume INTEGER, | |
stock_price_adj_close DECIMAL | |
); | |
SELECT aws_s3.table_import_from_s3( | |
'nyse', | |
'', -- columns | |
'(FORMAT CSV, DELIMITER E''\t'', HEADER true)', | |
aws_commons.create_s3_uri('datapyro-main', 'test/NYSE-2000-2001.tsv', 'eu-west-1'), | |
aws_commons.create_aws_credentials('ACCESS_KEY', 'SECRET_KEY', '') | |
); | |
select * from nyse limit 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment