2021年1月10日日曜日

Postgress(copyクエリ利用)

 以下、クエリになる。

---------------------------------------------------------------------

#!/bin/bash


DBNAME="dvdrental" # 接続するデータベース名

HOST="database-pg1.cksctvztkm5v.ap-northeast-1.rds.amazonaws.com"

tables=("actor")

day=$(date "+%m%d%Y%H%M")


# postgresqlでcopy出力

psql -U postgres -h $HOST -d $DBNAME -c "\COPY (select * from $tables where last_update::date = date 'now') TO '/tmp/$day"_""$tables".csv' WITH CSV DELIMITER ','"

----------------------------------------------------------------------



参照先:

https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/AuroraUserGuide/postgresql-s3-export.html


0 件のコメント:

コメントを投稿

EXOでMacStudioをクラスタリング

以下のMacStudio2台に、EXOを使ってクラスタリングを行います。 ①MacStudio(M1 MAX 32GB) ②MacStudio(M4 MAX 36GB) 1)導入方法は、以下を参照。 参照先: https://github.com/exo-explore/exo/...