Обсуждение: Download file from COPY ... TO with pgadmin

Поиск
Список
Период
Сортировка

Download file from COPY ... TO with pgadmin

От
Marco Lechner
Дата:

Hi,

 

Using COPY …TO it is possible to store e.g. the “value” of a bytea cell in a directory on the server. E.g. by this:

 

COPY (SELECT content FROM d_doc WHERE id = 'x123456') TO CONCAT('/tmp/mydoc.pdf’) (FORMAT binary);

 

As we do not have access to the postgresql fileserver (ssh, …), but can SELECT the value of the bytea cell, is It possible to download the bytea directly into a file on a client computer when using pgadmin? Is there a solution with the COPY … TO command, any pgadmin specific feature or any other simple solution?

 

Regards

Marco

 

 

 

 

i.A. Dr. Marco Lechner

Leiter Fachgebiet RN 1 │ Head RN 1

 

--

Bundesamt für Strahlenschutz │ Federal Office for Radiation Protection

Koordination Notfallschutzsysteme │ Coordination Emergency Systems │ RN 1

Rosastr. 9

D-79098 Freiburg

 

Tel.: +49 30 18333-6724

E-Mail: mlechner@bfs.de

www.bfs.de

🌐 Besuchen Sie unsere Website, folgen Sie uns auf Twitter und abonnieren Sie unseren 📢 Newsletter.

🔒 Informationen zum Datenschutz gemäß Artikel 13 DSGVO

💚 E-Mail drucken? Lieber die Umwelt schonen!

 

--

Hinweis zu Anhängen die auf .p7m/.p7c/.p7s oder .asc/.asc.sig enden:
Die .p7?- und .asc-Dateien sind ungefährliche Signaturdateien (digitale Unterschriften). In E-Mail-Clients mit S/MIME Konfiguration (.p7?) oder PGP-Erweiterung (.asc) dienen sie zur:
- Überprüfung des Absenders
- Überprüfung einer evtl. Veränderung des Inhalts während der Übermittlung über das Internet
Die Signaturdateien können ebenso dazu verwendet werden dem Absender dieser Signatur eine E-Mail mit verschlüsseltem Inhalt zu senden. In E-Mail-Clients ohne S/MIME Konfiguration oder PGP-Erweiterung erscheinen die Dateien als Anhang und können ignoriert werden.

 

Re: Download file from COPY ... TO with pgadmin

От
Erik Wienhold
Дата:
> On 31/01/2023 14:02 CET Marco Lechner <mlechner@bfs.de> wrote:
>
> Using COPY …TO it is possible to store e.g. the “value” of a bytea cell in a
> directory on the server. E.g. by this:
>
> COPY (SELECT content FROM d_doc WHERE id = 'x123456') TO CONCAT('/tmp/mydoc.pdf’) (FORMAT binary);
>
> As we do not have access to the postgresql fileserver (ssh, …), but can SELECT
> the value of the bytea cell, is It possible to download the bytea directly
> into a file on a client computer when using pgadmin? Is there a solution with
> the COPY … TO command, any pgadmin specific feature or any other simple solution?

Use psql with \copy which targets the client file system.  pgAdmin 5.4+ can also
launch psql.

--
Erik



AW: Download file from COPY ... TO with pgadmin

От
Marco Lechner
Дата:
Works as expected on both ways. Thnx.

-----Ursprüngliche Nachricht-----
Von: Erik Wienhold <ewie@ewie.name> 
Gesendet: Dienstag, 31. Januar 2023 14:58
An: Marco Lechner <mlechner@bfs.de>; pgsql-general@lists.postgresql.org
Betreff: Re: Download file from COPY ... TO with pgadmin

> On 31/01/2023 14:02 CET Marco Lechner <mlechner@bfs.de> wrote:
>
> Using COPY …TO it is possible to store e.g. the “value” of a bytea 
> cell in a directory on the server. E.g. by this:
>
> COPY (SELECT content FROM d_doc WHERE id = 'x123456') TO 
> CONCAT('/tmp/mydoc.pdf’) (FORMAT binary);
>
> As we do not have access to the postgresql fileserver (ssh, …), but 
> can SELECT the value of the bytea cell, is It possible to download the 
> bytea directly into a file on a client computer when using pgadmin? Is 
> there a solution with the COPY … TO command, any pgadmin specific feature or any other simple solution?

Use psql with \copy which targets the client file system.  pgAdmin 5.4+ can also launch psql.

--
Erik

Re: Download file from COPY ... TO with pgadmin

От
Adrian Klaver
Дата:
On 1/31/23 05:02, Marco Lechner wrote:
> Hi,
> 
> Using COPY …TO it is possible to store e.g. the “value” of a bytea cell 
> in a directory on the server. E.g. by this:
> 
> COPY (SELECT content FROM d_doc WHERE id = 'x123456') TO 
> CONCAT('/tmp/mydoc.pdf’) (FORMAT binary);
> 
> As we do not have access to the postgresql fileserver (ssh, …), but can 
> SELECT the value of the bytea cell, is It possible to download the bytea 
> directly into a file on a client computer when using pgadmin? Is there a 
> solution with the COPY … TO command, any pgadmin specific feature or any 
> other simple solution?

Read the docs:

https://www.pgadmin.org/docs/pgadmin4/6.19/import_export_data.html

> 
> Regards
> 
> Marco
> 
> i.A. Dr. Marco Lechner
> 
> Leiter Fachgebiet RN 1 │ Head RN 1
> 
> --

-- 
Adrian Klaver
adrian.klaver@aklaver.com