0

I am trying to store employee ID picture to my DB with the ID# as the primary key. Yes I know storing the images to the database will put a heavier load on the DB however when I try:

INSERT INTO `companydatabase`.`employee_pic` (`emp_id`, `emp_pic`) values(100, LOAD_FILE('D:\\ID.png'));
INSERT INTO employee_pic values(100, LOAD_FILE('D:\ID.png'));

it replies:

Error Code: 1048. Column 'emp_pic' cannot be null

Columns below:

emp_id     int(5)     Nullable = No
emp_pic    blob       Nullable = No

&

|Variable_name          |Value
-----------------------------------
|max_allowed_packet     |52428800

It's strange but when I use the GUI interface in workbench it uploads the image but the script it provides is useless:

INSERT INTO `companydatabase`.`employee_pic` (`emp_id`, `emp_pic`) VALUES ('100', ?);

The most important part comes back as a question sign???

NB: Sidenote this DB will be accessed using Python not PHP or Js. I just need to find out the MySQL query to upload the ID images to the DB, that is literally the only issue I have atm, I am using MySQL Workbench 8.0.

2
  • 1
    Try using the unix / instead of the windows back slash Commented Dec 10, 2018 at 19:43
  • I've tried that aswell Commented Dec 10, 2018 at 22:09

1 Answer 1

0

LOAD_FILE() is returning NULL. This may be because the path to the file is incorrect, or because the file is not present on the MySQL server, or because your MySQL user does not have the FILE privilege.

Sign up to request clarification or add additional context in comments.

1 Comment

the path is correct I checked and used multiple examples as reference, it has file privilege when I use the GUI option, "Load value from file..." it uploads the image and saves it after i click apply, however the script it shows doesn't help much "INSERT INTO companydatabase.employee_pic (emp_id, emp_pic) VALUES ('100', ?);"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.