[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] psql upgrade
From: |
Busser, Jim |
Subject: |
Re: [Gnumed-devel] psql upgrade |
Date: |
Sun, 24 Nov 2013 17:25:09 +0000 |
On 2013-11-24, at 4:13 AM, Sebastian Hilbert <address@hidden> wrote:
> Am Sonntag, 24. November 2013, 14:13:09 schrieb Vaibhav Banait:
>> How can I write the output of command \d substance_intake to file . There
>> is a large data which I can not capture onto the image.
>>
>> Vaibhav
>
> http://stackoverflow.com/questions/5331320/psql-save-results-of-command-to-a-file
>
> I have not tested this.
I had the interest to do so.. the first method
db=>\o out.txt
db=>select * from audit.log_episode where pk = 555;
db=>\q
can log into psql using gm-dbo (for example with psql -U gm-dbo -d gnumed_v18)
and will write to the user's local directory (for example,
~/Downloads/gnumed-client.1.4.1/client) from which psql is called. However, the
output is not very aesthetic:
pk_audit | orig_version | orig_when | orig_by | orig_tableoid | audit_action |
audit_when | audit_by | row_version | modified_when | modified_by | pk |
fk_health_issue | description | is_open | fk_encounter |
diagnostic_certainty_classification | summary
----------+--------------+-----------+---------+---------------+--------------+------------+----------+-------------+---------------+-------------+----+-----------------+-------------+---------+--------------+-------------------------------------+---------
(0 rows)
The second method will output the file to a directory on the *server*
COPY (select * from audit.log_episode where pk = 555) TO
'/tmp/query.csv' (format csv, delimiter ';');
notes:
1) relative paths in TO are not supported (thus no ~ or ./ )
2) the system user postgres must have write permissions in the TO directory,
thus the need to output to /tmp/ or to a directory created for use by postgres,
as shown with examples here
http://www.gistutor.com/postgresqlpostgis/10-intermediate-postgresqlpostgis-tutorials/39-how-to-import-or-export-a-csv-file-using-postgresql-copy-to-and-copy-from-queries.html
-- Jim
- [Gnumed-devel] Psql upgrade, Vaibhav Banait, 2013/11/15
- [Gnumed-devel] psql upgrade, Vaibhav Banait, 2013/11/24
- Re: [Gnumed-devel] psql upgrade, Sebastian Hilbert, 2013/11/24
- Re: [Gnumed-devel] psql upgrade,
Busser, Jim <=
- Re: [Gnumed-devel] psql upgrade, Karsten Hilbert, 2013/11/24
- Re: [Gnumed-devel] psql upgrade, Busser, Jim, 2013/11/24
- Re: [Gnumed-devel] psql upgrade, Busser, Jim, 2013/11/24
Re: [Gnumed-devel] psql upgrade, Karsten Hilbert, 2013/11/24
- Re: [Gnumed-devel] psql upgrade, Karsten Hilbert, 2013/11/24
- Re: [Gnumed-devel] psql upgrade, Sebastian Hilbert, 2013/11/25
- Re: [Gnumed-devel] psql upgrade, Karsten Hilbert, 2013/11/25
- Re: [Gnumed-devel] psql upgrade, Sebastian Hilbert, 2013/11/25
- Re: [Gnumed-devel] psql upgrade, Karsten Hilbert, 2013/11/25
- Re: [Gnumed-devel] psql upgrade, Sebastian Hilbert, 2013/11/25