This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert image in postgreSql data base

 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know how can i insert an image Type "bytea" in postgresql database?
Thank you in advance

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? What problems are you having?
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my database table which i write into PgAdmin III:

And when i want to add a line like this :

and when i add a new line, it doesn't work
insert into category(category_name,category_image) values('tablette', lo_import('D:\image.jpg'));


 
Paul Clapham
Sheriff
Posts: 21567
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you have two different versions there. One with single quotes around the file name and one with double quotes around it. So "doesn't work" is not only useless -- read our FAQ page ItDoesntWorkIsUseless -- you don't even say what doesn't work.
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A propors the quotes, it's a typo
Here is the insert query:

It doesn't work, i mean the line doesn't added in my table and an error message appears as followings:
 
Sarra Sakka
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem here that the function "lo_import" is defined for type "Oid" and not for type "bytea"
But I have not found the equivalent of functions and lo_import lo_export for type "bytea", can you help me please?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic