The Postgres conversion function is often used to instantly help PMs understand the actual status of current users and to record common commands underneath. First install the Postgres environment, this side is actually the way to use Docker to start a new Postgres DB.
The environment
parameter above can be freely adjusted, and then the database can be started for app streaming via docker-compose up -d
.
Login to Postgres
Assuming the Docker container does not have an expos 5432 port, you basically have to log in to the container. But if expose out, then the Host machine needs to install the postgres client package to be able to log in, and we can log in to the container directly to avoid the problem that the clinet tool and server version are not the same.
|
|
where db
is the name in docker-compose.yml, please change it yourself. After entering the container, you can login to the postgres database by using the psql command.
|
|
Exporting data to CSV format
After logging into Postgres, a single table can be exported to csv format with a simple command
|
|
If you just want a few columns in the table, you can change it to the following
|
|
Or to organize the data through SQL
|
|
You can also convert to Taiwan time for UTC time
Take out the data
The above data will be stored in /data.csv
in the container, so you can pull out the data by docker cp command. Find the postgres container ID with docker ps
and run the following command
|
|
Then you can automate the process for all the above steps.