Sir please tell me how to import image in database

0 votes
Apr 1, 2020 in Database by Soumadip
• 120 points

reshown Apr 1, 2020 by Sirajul 439 views

1 answer to this question.

0 votes

Hello soumadip,

(Assuming you are using mysql database)

You will  able to get it done by moving the image(fileName.jpg) file first in to below folder(in my case) C:\ProgramData\MySQL\MySQL Server 7.2\Uploads and then I executed below command and it works for me,

INSERT INTO Niraj(ID,IMAGE) VALUES(1,LOAD_FILE('C:/ProgramData/MySQL/MySQL Server 7.2/Uploads/fileName.jpg'));

Here assuming the images is on my local computer, in the images folder:

//Create the table
 CREATE TABLE images (
        picid int NOT NULL AUTO_INCREMENT,
        description VARCHAR(40),
        image BLOB,
        PRIMARY KEY (picid));

// Insert the row
INSERT INTO images VALUES
        (NULL,'picture of a frog','c\:images\frog.png');

Hope this helps.

Thank you!!

answered Apr 1, 2020 by Niroj
• 82,840 points

Related Questions In Database

0 votes
0 answers

How to store image in SQLite database

I want to upload an image from ...READ MORE

Aug 22, 2022 in Database by Kithuzzz
• 28,700 points
781 views
0 votes
2 answers
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
866 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
19,997 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 8,940 points
213 views
0 votes
0 answers

How to change column datatype in SQL database without losing data?

I have a SQL Server database, and ...READ MORE

Feb 25, 2022 in Database by Vaani
• 7,020 points
214 views
0 votes
0 answers

How to retrieve data from sqlite database in android and display it in TextView

I'm studying Android. I'm having trouble solving ...READ MORE

Aug 11, 2022 in Database by Kithuzzz
• 28,700 points
1,952 views
0 votes
0 answers

Import .bak file to a database in SQL server

I have a file with .bak extension. How ...READ MORE

Aug 14, 2022 in Database by Kithuzzz
• 28,700 points
85 views
0 votes
1 answer

How to empty a redis database?

Hello @kartik, You have two options: FLUSHDB - clears currently ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
326 views
0 votes
1 answer

How to take MySQL database backup using MySQL Workbench?

Hii, You can export like this: Hope this is ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
589 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP