Issue storing images in Postges database - permission denied - sql

I have a small database in which I want to store images in a separate table. I have been reading different methods and believe due to the small size of the DB there is no issue in physically storing the image within the DB.
I have been reading and trying to get the sql code correct in order to upload one image into a new table. However I am running into "SQL Error [42501]: ERROR: could not open file.... for reading: Permission denied".
I have tried to change permission access by clicking Command + I on the folder and at the bottom adding "postgres" with "Read & Write" privileges. I closed DBeaver and still not luck.
Is my approach and sql code correct for uploading and image? How do I get around permissions?
create table category (
"id_category" SERIAL,
"category_name" TEXT,
"category_image" bytea,
constraint id_cat_pkey primary key ("id_category"))without oids;
insert into category (category_name,category_image) values('MANGO', pg_read_binary_file('tmp/IMG_2405.jpeg')::bytea)

I was able to upload the image to postgres. I had to move the picture to a folder with in the same directory as postgres. I am still working how to give permission to folders outside of postgres.

Related

Problems Loading data from CSV into a PostgreSQL table with PGADMIN

I am at a loss. I am on a mac using PG Admin 4 with PostgreSQL I tried to use the import/export data wizard when you right click on the table I created...and get this error ERROR: extra data after last expected column...all of the colomns match up and there is no additional data. I don't know what needs to change...
So then I tried to create it with the quarry tool with the following code (renaming things to put here):
create schema schema_name;
create table schema_name.tablename( column1 text, column2 text...); ***all the columns are a text data type***
copy schema_name.tablename
from '/Users/me/downloads/filename.csv'
delimiter ',' header csv;
and get this error message:
ERROR: could not open file "/Users/me/downloads/filename.csv" for reading: Permission denied
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501
Going to properties for that database, and then to security, and privileges I made public all privileges. But that did nothing. And so I am here to ask yall for help.
Successfully import the data from the CSV.

error loading table on bigquery dashboard but queries works fine

I clicked a table on bigquery dashboard, got this error:
However, I can get data when I do a select on this table. (That means the table does exist)
I already have the highest admin privilege so it shouldn't be a permission issue.
I created this table with python script, which collects data, writes into a csv file, and upload the csv file to bigquery everyday. After I created the table I once changed the schema both in the script and on the dashboard. Not sure if that's the cause, but the table loading error occurred several days after I changed the schema.
If you have Addblock extensions, this might be the root cause of this issue. Thus, try disabling it, then try running your query again.
Hope it helps.

difficulty with the creation of the external table

i have a strange problem with the creation of the external table.
I have an external table "X" under the user X. If i try to create another External Table by doing the copy and paste of sql code, i have this error when i do SELECT * FROM x
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file CFO_PC.csv in EPM_SERVICE_DATA not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
the EPM_SERVICE_DATA is the directory where is the file CFO_PC.csv
My user have the grand read and write on this directory.
have you no idea what the problem is?
Sorry for my english...
Is it the same file? CFO_PC.csv Then it should be locked by the original external table.
Copy it, and create a new external table using the copy (make sure that Operating System write/read privileges are correct for the Oracle Database group.
I have resolved, i have copied the sql code from sql developer and it added the code that, it even plays.
LOCATION ( 'CFO_PC.csv' ) is correct
LOCATION ( EPM_SERVICE_DATA: 'CFO_PC.csv' ) not correct

How to add database to pervasive sql Control Center?

I've never touched PervasiveSql before and now I have a bunch of .ddf and .Btr files. I read that all I had to do was create a new database in the control center and point to the folder that contains these files.
When I do this and look at the database there is nothing in it. Since I am new to Pervasive, I'm more than likely sure that I'm doing something wrong.
EDIT: Added a screen shot after running command prompt
To create a database name in the PCC, you need to connect to the engine then right click the engine name and select New then Database. Once you do that, the following dialog should be displayed:
Enter the database name, and path. The path being where the DDFs are located. In most cases the default options are sufficient.
A longer process is documented at http://docs.pervasive.com/products/database/psqlv11/wwhelp/wwhimpl/js/html/wwhelp.htm#href=uguide/using.02.5.html.
If you pointed to a directory that had DDF files (FILE.DDF, FIELD.DDF,and INDEX.DDF) when you created the database name, you should see tables listed.
If you pointed to a directory that does not have DDF files, the database will still be created but will have no tables defined. You'll either need to get DDFs from the vendor or create the table entries using CREATE TABLE (with IN DICTIONARY clauses) or use DDF BUilder to add table entries.
Based on your screen shot, you only have 10 records in FILE.DDF. This is not enough. There are minimum system tables required (X$FILE, X$FIELD, X$INDEX, and a few others). It appears your DDFs are not a valid set. Contact the client / vendor that provided the DDFs and ask for a set that include all of the table definitions.
Once you have tables listed in your Database Name, you can use ODBC to access the data.

How can I store images in BLOB?

I can not find useful code for how storing the images into BLOB ,please help me with some code and also can I show those images from MySQL to my desktop pane in GUI?
If the image is located on your MySQL host, you could use the LOAD_FILE() command for storing an image in a BLOB:
-- Using the following table as an example:
CREATE TABLE MyTable (
image BLOB
);
-- This will insert a file in a BLOB column.
INSERT INTO MyTable (image) VALUES(LOAD_FILE('/tmp/image.png'));
Make sure that the image file is readable by MySQL, and also make sure that your MySQL user has the FILE privilege.
To grant the FILE privilege, log-in as root and execute:
GRANT FILE ON *.* TO 'mysql_user'#'localhost';
Easiest way is to store the contents of some binary image file in the blob, extract them, write them to a file and open that file with an image file parser of some kind. Or, if you're really tricky, use that same image parser to read the data from memory directly after pulling the blob out of the DB.
I'm assuming you've got some sort of ImagePane widget that can handle the GUI display if you can provide an image file to it.