O
O
Oleg Petrov2017-08-25 18:32:40
PostgreSQL
Oleg Petrov, 2017-08-25 18:32:40

How to copy the queries that the program makes to Postgres sql?

The program makes queries to the database in the Postgres sql 8.4 format
. I want to copy these queries into my program.
I was told that there is a certain service mode that logs all requests to the database.
How to enable it or how to get those requests that the program makes?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
vman, 2017-08-25
@vman

you need to edit the postgresql.conf file
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_statement = 'all'
logging_collector = on
then restart the server
service postgresql restart

M
Melkij, 2017-08-25
@melkij

In addition to log_statement = 'all', you can set the log_min_duration_statement setting to 0 - it can also log all requests.
If there are a lot of requests through the database not only from the necessary program, then both log_statement and log_min_duration_statement can be set only for the user on whose behalf the program executes requests. For example,

alter user melkij set log_min_duration_statement = 0;

A
Alexey Shashenkov, 2017-08-25
@teknik2008

He left to guess what the program was.

O
Oleg Petrov, 2017-08-25
@Smeilz1

1) I set all the settings + log_min duration_statement = 0
2)
I rebooted 3) I launched the program, made a couple of requests through it.
4) THIS log:
2017-08-25 20:57:20 MSDLOG: database system was shut down at 2017-08-25 20:57:04 MSD
2017-08-25 20:57:20 MSDLOG: database system is ready to accept connections
2017-08-25 20:57:21 MSDLOG: autovacuum launcher started
2017-08-25 20:58:35 MSDLOG: could not receive data from client: No connection could be made because the target machine actively refused it.
2017-08-25 20:58:35 MSDLOG: unexpected EOF on client
connection
2017-08-25 20:58:35 MSDLOG: unexpected EOF on client
connection
2017-08-25 20:58:35 MSDLOG: unexpected EOF on client connection
-------------------------
What did I do wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question