Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using pg_read_file read file in desktop PostgreSQL

I wanted to how to read a file in my desk top using pg_read_file in PostgreSQL

pg_read_file(filename text [, offset bigint, length bigint])

my query

select pg_read_file('/root/desktop/new.txt' , 0 , 1000000);

error

ERROR:  absolute path not allowed

UPDATE

like image 460
Arjun Raj Avatar asked Feb 27 '14 16:02

Arjun Raj


2 Answers

pg_read_file can read the files only from the data directory path, if you would like to know your data directory path use:

SHOW  data_directory;

I think that you can resolve you problem by looking to this post

like image 113
Houari Avatar answered Oct 06 '22 13:10

Houari


If you're using psql you can use \lo_import to create a large object from a local file.

The pg_read_file tool only allows reads from server-side files.

like image 44
Craig Ringer Avatar answered Oct 06 '22 13:10

Craig Ringer