Reputation: 984
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
Upvotes: 7
Views: 37242
Reputation: 21
To read the content of a file from PostgreSQL you can use this.
CREATE TABLE demo(t text);
COPY demo from '[FILENAME]';
SELECT * FROM demo;
Each text-line in a SQL-ROW. Useful for temporary transfers.
Upvotes: 2
Reputation: 1
lo_import(file path) will generate an oid.This may solve your problem. you can import any type of file using this (even image)
Upvotes: 0
Reputation: 324385
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.
Upvotes: 8
Reputation: 5621
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
Upvotes: 12