Use psql’s \copy for a multi-line query

The working solution I have right now is to create a temporary view, which can be declared over multiple lines, then select from it in the \copy command, which fits comfortably on one line. db=> CREATE TEMP VIEW v1 AS db-> SELECT i db-> FROM generate_series(1, 2) AS i; CREATE VIEW db=> \cd /path/to/a/really/deep/directory/structure/on/client db=> … Read more

Show query result column types (PostgreSQL)

It is possible to get any SELECT query result column type. Example Given the following query and result, let’s answer the question *”What is the column type of all_ids?”* SELECT array_agg(distinct “id”) “all_ids” FROM “auth_user”; all_ids ——————————————– {30,461577687337538580,471090357619135524} (1 row) We need a mechanism to unveil the type of “all_ids”. On the postgres mailing list … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)