Обсуждение: How to save a image file in a postgres data field.

Поиск
Список
Период
Сортировка

How to save a image file in a postgres data field.

От
richard terry
Дата:
I want to be able to save an image, say myimage.png, into the database, and
having difficulty with understanding the postgres documentation.

The nearest I can figure is that there is a field called bytea ?? is this the
correct one.

If so, I wondered if anyone could give me a simple line of sql code which
would demonstrate how to do this.

Regards and thanks in advance.

Richard

Re: How to save a image file in a postgres data field.

От
"Obe, Regina"
Дата:

You can do bytea (which stores the image as a bytearray) or Large Object support (lo) which stores the oid reference to the image and stores it in another table.

What language are you using?  Check way at the bottom of this page gives an example of storing files in bytea using .NET ADO driver as well as using the LO (Large Object support).

Even if its not the language you use, could provide you with some ideas.

Bytea example Look for "Working with binary data and bytea datatype"
For LO look for "Working with large object support" in the below link
http://npgsql.projects.postgresql.org/docs/1.0/manual/UserManual.html

Hope that helps,
Regina


-----Original Message-----
From: pgsql-novice-owner@postgresql.org on behalf of richard terry
Sent: Thu 8/28/2008 5:26 PM
To: 'PostgreSQL Novice'
Subject: [NOVICE] How to save a image file in a postgres data field.

I want to be able to save an image, say myimage.png, into the database, and
having difficulty with understanding the postgres documentation.

The nearest I can figure is that there is a field called bytea ?? is this the
correct one.

If so, I wondered if anyone could give me a simple line of sql code which
would demonstrate how to do this.

Regards and thanks in advance.

Richard

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice



The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.


Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper.

Re: How to save a image file in a postgres data field.

От
richard terry
Дата:
On Fri, 29 Aug 2008 08:01:16 am Obe, Regina wrote:

I've done a bit of research/tried some got and got part of the way.

I can convert a picture to a string to save but when I try and insert it into
the database I get the following:


Query failed:ERROR: invalid byte sequence for encoding "UTF8":0x89 HINT: This
error can also happen if the byte sequence does not match the encoding
expected by the server, which is controlled  by "client_encoding"

One of the users from  the Sydney user group Sydpug answered and helped me in
part  but mentioned this:
=============================================
Hear your pain, this was all done on debian linux. binmode was a gotcha

I've done it with a bytea column like this

use DBI ;
use DBD::Pg qw(:pg_types); #Required for us to use the *bytea* column
=============================================

I can't interpet the last line which (admittedly in another language) he says
is needed to use the bytea type.

Any further help appreciated.

Richard


> You can do bytea (which stores the image as a bytearray) or Large Object
> support (lo) which stores the oid reference to the image and stores it in
> another table.
>
> What language are you using?  Check way at the bottom of this page gives an
> example of storing files in bytea using .NET ADO driver as well as using
> the LO (Large Object support).
>
> Even if its not the language you use, could provide you with some ideas.
>
> Bytea example Look for "Working with binary data and bytea datatype"
> For LO look for "Working with large object support" in the below link
> http://npgsql.projects.postgresql.org/docs/1.0/manual/UserManual.html
>
> Hope that helps,
> Regina
>
>
> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org on behalf of richard terry
> Sent: Thu 8/28/2008 5:26 PM
> To: 'PostgreSQL Novice'
> Subject: [NOVICE] How to save a image file in a postgres data field.
>
> I want to be able to save an image, say myimage.png, into the database, and
> having difficulty with understanding the postgres documentation.
>
> The nearest I can figure is that there is a field called bytea ?? is this
> the correct one.
>
> If so, I wondered if anyone could give me a simple line of sql code which
> would demonstrate how to do this.
>
> Regards and thanks in advance.
>
> Richard



Re: How to save a image file in a postgres data field.

От
"Obe, Regina"
Дата:
> =============================================
> Hear your pain, this was all done on debian linux. binmode was a
gotcha

> I've done it with a bytea column like this

> use DBI ;
> use DBD::Pg qw(:pg_types); #Required for us to use the *bytea* column
=============================================

> I can't interpet the last line which (admittedly in another language)
he says 
> is needed to use the bytea type.

> Any further help appreciated.

> Richard

Rich,

Unfortunately I don't know perl too well so the above is pretty cryptic
to me too. From my cursory reading - seems the above just registers
PostgreSQL datatypes with DBD.

Which language are you programming in?  My default encoding for my
database is UTF-8, but I don't recall having to do anything special that
wasn't already implicitly done by the driver I was using and I think the
npgsql ADO.NET driver already takes care of registering the Pg bytea and
other PG specific data types so my guess is you are not using .NET.
Then again I don't do too much of storing images in the database.

Seems then that whatever you are doing is not translating your data to
bytea format correctly.

Hope that helps,
Regina



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.


Re: How to save a image file in a postgres data field.

От
richard terry
Дата:
On Tue, 2 Sep 2008 10:40:59 pm Obe, Regina wrote:
> > =============================================
> > Hear your pain, this was all done on debian linux. binmode was a
>
> gotcha
>
> > I've done it with a bytea column like this
> >
> > use DBI ;
> > use DBD::Pg qw(:pg_types); #Required for us to use the *bytea* column
>
> =============================================
>
> > I can't interpet the last line which (admittedly in another language)
>
> he says
>
> > is needed to use the bytea type.
> >
I've made a little progress with some help from a gambas user but still
failing. Perhaps these two sample queries which stall will prompt someone to
guide me in the correct direction:

On Tue, 2 Sep 2008 09:48:55 pm you wrote:
Ok, that got me a bit further: This is the resultant (failed) insert query .
First try using $$ as the delimiters as per my code gives this and fails:

insert into

clin_consult.temp_image(piccie)values($$\\211PNG\\015\\012\\032\\012\\000\\000\\000\\015IHDR\\000\\000\\000\\232\\000\\000\\000\\311\\010\\002\\000\\000\\000T\\207\\274\\031\\000\\000\\005\\266IDATx\\234\\355\\235\\331\\266\\2330\\020\\004\\345\\234\\374\\377/\\223\\007\\345\\020\\007\\373\\012!f\\351i\\272\\236\\262\\330

M1#!\\263\\274\\266mk\\202\\205_\\331\\015\\020\\226H\'\\025\\322I\\205tR!
\\235TH\'\\025\\322I\\205tR\\361;\\273\\001f\\274^/\\333\\015V\\134`!
\\311Ns\\227N\\333\\364\\206A\\247_\\334\\313\\031e\\320)v\\244\\223\\212\\362:
\\313\\325CW\\312\\353\\364\\246\\326\\341R[g\\255X\\007P\\370\\274s\\354\\362\\352Y#\\307\\221Q5;
\\265h\\360\\225\\252:
\\307\\330\\272)\\224\\270%u\\026\\212o0\\365t\\236\\272\\344
(\\233k\\024\\323\\351\\352r\\360\\335*\\365\\240\\222N\\345\\345)5NT\\252$G:

\\005\\262s\\322\\245wj\\2268\\244\\320u\\006\\273\\254^\\256\\241u\\202\\344e!puf\\271,=\\277\\005\\325\\251\\274\\134\\003T\\347\\014r\\371\\311\\0130
(\\010\\347\\227\\2036\\000Fl\\007.;

\\021\\134\\216A\\036A\\341t\\216Iw\\011\\016\\226N\\333_\\244\\3570\\336\\027l\\202\\002\\351\\204\\215Q!Pt\\002\\016\\231\\025\\023\\024B\'\\240\\313\\242\\344\\353DvY\\3560J\\326\\211Y\\262&\\001l|

\\246\\316\\231p\\244\\347G\\255\\0214\\277\\330\\016Hw9\\003\\224\\3214\\235\\310C\\346\\001\\234\\226\\234\\002\\232\\235h\\021\\254Rrst\\342\\254\\376\\314S\\302h\\202N\\220\\236\\233\\203\\320\\257h\\235\\205\\206\\314ON\\333\\226n\\024t\\354\\024k\\204\\352,
\\235\\232\\035\\360\\004\\005\\312N|\\227\\035d\\243q:+\\316f\\177\\002\\326
(Pv\\326b\\306h\\274\\324 \\235L\\251y\\211`\\243\\021:

\\323\\247\\357NL\\036\\205\\221\\335w\\327I0\\233\\375J\\357\\327\\274\\321\\030\\251\\276:Y]\\2763\\337\\205\\000\\243\\216:

\\237\\340\\262\\263m\\033H\\232z\\335\\256\\313:^\\016\\330\\266m\\262\\327~\\301\\261\\327Y\\372n\\241\\367\\306/\\264p\\336\\350\\362.
\\306\\030\\337\\243R\\335\\345
{\\303\\016\\177}\\377w\\303\\235\\332\\206\\302,;
\\347;Y\\302\\345\\347\\377\\356\\177\\356\\037\\033\\177\\276M\\007\\344\\322\\014\\371|
k&\\033"p\\331\\377\\260\\253:|\\340\\263\\331\\247:
\\277ng\\200\\215\\210\\233

[\\311\\035*L\\370I\\336i\\276\\316tg\\2412\\337\\211\\322\\255b[\\327\\345\\370\\366\\315IUw\\3662\\376\\326\\362\\336o|
\\263\\254\\313w\\356\\334\\226
{(\\321\\2276~\\312Z\\304Vtr\\210\\334\\371\\251;
\\313\\313=\\373\\027o\\316\\201\\027Bw\\241\\330>pe`\\222C\\334\\255\\002\\265Pug\\277\\020_7b\\350!;

\\234-\\344\\216\\235\\357\\134m\\306Tv\\336l\\226Ut\\3748\\234\\237\\200\\267v\\200\\256F\\370G\\267\\030\\340r~\\311\\376*\\226k\\266WW,

\\021x\\257\\264\\301U\\344\\260\\240h\\262M3\\235\\247+^\\260\\025lr\\321\\316\\273\\015_\\247\\307W\\357\\231\\234\\3229N;XO\\227H\\357\\305\\327\\006\\134]x\\232\\315\\316\\257F\\323C\\200L\\330\\270s9;?
\\2776\\370L\\271\\341\\223\\011\\315l\\251@\\271\\012\\3769\\270\\216P\\312N\\027tS\\2030\\300^\\247\\246\\273\\211
(;

\\355I<G\\227N*\\260\\356\\276\\0267Qv\\306\\0210\\253\\220Nc\\010\\237\\215\\240\\311m\\026p\\317\\025\\022wP\\261\\265$\\375gD=\\304\\215\\012/\\235\\032>SP\\2615#\\275\\3226\\351$\\303Q\\247\\352m<9\\2572\\017\\270l\\356\\346m\\361\\206D\\356\\235\\263\\330\\036\\206\\261\\347\\314\\245\\011u~\\225\\367\\020\\243\\276:5|
\\006C\\230\\235OF:\\251 \\324\\271|

w\\000\\001\\270o9\\272\\303A\\336C\\134\\266\\254\\363\\316\\000\\202\\025\\202\\314\\234\\011\\213\\355\\223q\\327\\371\\234B\\207\\200\\262\\323\\227\\340\\243Y:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251p\\327\\011\\362\\014\\210\\207\\240\\354\\244B:

\\251H\\323\\251\'\\232x\\340\\253S\\003gp\\004Tl\\251p\\324\\251\\324\\214\\307\\345\\231\\354\\247")\\007N\\316\\027o()\\0231\\3269\\343\\22225\\307\\204\\035\\342\\232\\012Q!
\\235A\\304$\\250\\336\\020H\\205\\261\\316\\311qQF\\235\\340|

\\026\\374c\\261\\3279?q}\\275^LR\\021f\\354\\371\\2572\\227QCB\\337\\3247&=\\026\\367\\031w6\\240\\203@\\217\\366\\257^{\\021\\032\\357\\236\\235\\177ws\\261\\253\\2652u\\262w\\014\\331\\331\\331\\266\\215u@\\205jj\\350\\211\\012\\237Q\\264\\231AP\\261\\375o\\227W<\\301V]\\314^$\\350l\\250\\261\\230\\007-)wrt\\266\\262F\\301\\233\\235\\246\\363_\\013`\\246\\205\\247\\200\\273l\\010:
[\\005\\243\\370";\\020:;\\200W2,

\\314\\256s\\343\\011\\244\\263\\201\\031\\255\\270\\364\\201\\245\\263\\223~!`\\271\\244\\334)\\371\\262\\344\\036\\356\\224KJ?
\\001\\021\\331A\\274V(\\353\\222\\206\\352.
\\033f\\261\\355\\204\\235\\252\\257\\035\\026\\230q\\303\\325\\331\\374O\\017\\226\\363\\0336h\\320:
\\233\\233Q>\\221\\035t\\235\\315\\324

(\\253\\305\\035\\304\\251\\320\\001\\253\\237\\325\\350]\\266\\022\\331\\271\\263<9z\\202\\310N%\\235\\235KR\\237#\\262SOg\\363\\277P\\241bL:
%uv\\314\\245\\326\\015\\305Na\\235\\315\\316h\\351
\\274S[g\\273m\\264z\\367\\017\\224\\327\\331\\270V\\351n\\302\\240\\263\\325\\271Z\\300\\233\\222?
\\220-C,
\\262C\\222\\235\\015\\340v\\037\\004xt\\266\\037\\2142u\\360\\024*\\235\\242\\300\\022\\274\\230G:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\370\\003>\\241\\324n\\304~\\303\\331\\000\\000\\000\\000IEND\\256B`\\202$$)

Second try using ' as delimeters gives this and fails, but adds a hint:

insert into

clin_consult.temp_image(piccie)values('\\211PNG\\015\\012\\032\\012\\000\\000\\000\\015IHDR\\000\\000\\000\\232\\000\\000\\000\\311\\010\\002\\000\\000\\000T\\207\\274\\031\\000\\000\\005\\266IDATx\\234\\355\\235\\331\\266\\2330\\020\\004\\345\\234\\374\\377/\\223\\007\\345\\020\\007\\373\\012!f\\351i\\272\\236\\262\\330

M1#!\\263\\274\\266mk\\202\\205_\\331\\015\\020\\226H\'\\025\\322I\\205tR!
\\235TH\'\\025\\322I\\205tR\\361;\\273\\001f\\274^/\\333\\015V\\134`!
\\311Ns\\227N\\333\\364\\206A\\247_\\334\\313\\031e\\320)v\\244\\223\\212\\362:
\\313\\325CW\\312\\353\\364\\246\\326\\341R[g\\255X\\007P\\370\\274s\\354\\362\\352Y#\\307\\221Q5;
\\265h\\360\\225\\252:
\\307\\330\\272)\\224\\270%u\\026\\212o0\\365t\\236\\272\\344
(\\233k\\024\\323\\351\\352r\\360\\335*\\365\\240\\222N\\345\\345)5NT\\252$G:

\\005\\262s\\322\\245wj\\2268\\244\\320u\\006\\273\\254^\\256\\241u\\202\\344e!puf\\271,=\\277\\005\\325\\251\\274\\134\\003T\\347\\014r\\371\\311\\0130
(\\010\\347\\227\\2036\\000Fl\\007.;

\\021\\134\\216A\\036A\\341t\\216Iw\\011\\016\\226N\\333_\\244\\3570\\336\\027l\\202\\002\\351\\204\\215Q!Pt\\002\\016\\231\\025\\023\\024B\'\\240\\313\\242\\344\\353DvY\\3560J\\326\\211Y\\262&\\001l|

\\246\\316\\231p\\244\\347G\\255\\0214\\277\\330\\016Hw9\\003\\224\\3214\\235\\310C\\346\\001\\234\\226\\234\\002\\232\\235h\\021\\254Rrst\\342\\254\\376\\314S\\302h\\202N\\220\\236\\233\\203\\320\\257h\\235\\205\\206\\314ON\\333\\226n\\024t\\354\\024k\\204\\352,
\\235\\232\\035\\360\\004\\005\\312N|\\227\\035d\\243q:+\\316f\\177\\002\\326
(Pv\\326b\\306h\\274\\324 \\235L\\251y\\211`\\243\\021:

\\323\\247\\357NL\\036\\205\\221\\335w\\327I0\\233\\375J\\357\\327\\274\\321\\030\\251\\276:Y]\\2763\\337\\205\\000\\243\\216:

\\237\\340\\262\\263m\\033H\\232z\\335\\256\\313:^\\016\\330\\266m\\262\\327~\\301\\261\\327Y\\372n\\241\\367\\306/\\264p\\336\\350\\362.
\\306\\030\\337\\243R\\335\\345
{\\303\\016\\177}\\377w\\303\\235\\332\\206\\302,;
\\347;Y\\302\\345\\347\\377\\356\\177\\356\\037\\033\\177\\276M\\007\\344\\322\\014\\371|
k&\\033"p\\331\\377\\260\\253:|\\340\\263\\331\\247:
\\277ng\\200\\215\\210\\233

[\\311\\035*L\\370I\\336i\\276\\316tg\\2412\\337\\211\\322\\255b[\\327\\345\\370\\366\\315IUw\\3662\\376\\326\\362\\336o|
\\263\\254\\313w\\356\\334\\226
{(\\321\\2276~\\312Z\\304Vtr\\210\\334\\371\\251;
\\313\\313=\\373\\027o\\316\\201\\027Bw\\241\\330>pe`\\222C\\334\\255\\002\\265Pug\\277\\020_7b\\350!;

\\234-\\344\\216\\235\\357\\134m\\306Tv\\336l\\226Ut\\3748\\234\\237\\200\\267v\\200\\256F\\370G\\267\\030\\340r~\\311\\376*\\226k\\266WW,

\\021x\\257\\264\\301U\\344\\260\\240h\\262M3\\235\\247+^\\260\\025lr\\321\\316\\273\\015_\\247\\307W\\357\\231\\234\\3229N;XO\\227H\\357\\305\\327\\006\\134]x\\232\\315\\316\\257F\\323C\\200L\\330\\270s9;?
\\2776\\370L\\271\\341\\223\\011\\315l\\251@\\271\\012\\3769\\270\\216P\\312N\\027tS\\2030\\300^\\247\\246\\273\\211
(;

\\355I<G\\227N*\\260\\356\\276\\0267Qv\\306\\0210\\253\\220Nc\\010\\237\\215\\240\\311m\\026p\\317\\025\\022wP\\261\\265$\\375gD=\\304\\215\\012/\\235\\032>SP\\2615#\\275\\3226\\351$\\303Q\\247\\352m<9\\2572\\017\\270l\\356\\346m\\361\\206D\\356\\235\\263\\330\\036\\206\\261\\347\\314\\245\\011u~\\225\\367\\020\\243\\276:5|
\\006C\\230\\235OF:\\251 \\324\\271|

w\\000\\001\\270o9\\272\\303A\\336C\\134\\266\\254\\363\\316\\000\\202\\025\\202\\314\\234\\011\\213\\355\\223q\\327\\371\\234B\\207\\200\\262\\323\\227\\340\\243Y:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251p\\327\\011\\362\\014\\210\\207\\240\\354\\244B:

\\251H\\323\\251\'\\232x\\340\\253S\\003gp\\004Tl\\251p\\324\\251\\324\\214\\307\\345\\231\\354\\247")\\007N\\316\\027o()\\0231\\3269\\343\\22225\\307\\204\\035\\342\\232\\012Q!
\\235A\\304$\\250\\336\\020H\\205\\261\\316\\311qQF\\235\\340|

\\026\\374c\\261\\3279?q}\\275^LR\\021f\\354\\371\\2572\\227QCB\\337\\3247&=\\026\\367\\031w6\\240\\203@\\217\\366\\257^{\\021\\032\\357\\236\\235\\177ws\\261\\253\\2652u\\262w\\014\\331\\331\\331\\266\\215u@\\205jj\\350\\211\\012\\237Q\\264\\231AP\\261\\375o\\227W<\\301V]\\314^$\\350l\\250\\261\\230\\007-)wrt\\266\\262F\\301\\233\\235\\246\\363_\\013`\\246\\205\\247\\200\\273l\\010:
[\\005\\243\\370";\\020:;\\200W2,

\\314\\256s\\343\\011\\244\\263\\201\\031\\255\\270\\364\\201\\245\\263\\223~!`\\271\\244\\334)\\371\\262\\344\\036\\356\\224KJ?
\\001\\021\\331A\\274V(\\353\\222\\206\\352.
\\033f\\261\\355\\204\\235\\252\\257\\035\\026\\230q\\303\\325\\331\\374O\\017\\226\\363\\0336h\\320:
\\233\\233Q>\\221\\035t\\235\\315\\324

(\\253\\305\\035\\304\\251\\320\\001\\253\\237\\325\\350]\\266\\022\\331\\271\\263<9z\\202\\310N%\\235\\235KR\\237#\\262SOg\\363\\277P\\241bL:
%uv\\314\\245\\326\\015\\305Na\\235\\315\\316h\\351
\\274S[g\\273m\\264z\\367\\017\\224\\327\\331\\270V\\351n\\302\\240\\263\\325\\271Z\\300\\233\\222?
\\220-C,
\\262C\\222\\235\\015\\340v\\037\\004xt\\266\\037\\2142u\\360\\024*\\235\\242\\300\\022\\274\\230G:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\370\\003>\\241\\324n\\304~\\303\\331\\000\\000\\000\\000IEND\\256B`\\202')
WARNING:  nonstandard use of \\ in a string literal
LINE 1: insert into clin_consult.temp_image(piccie)values('\\211PNG\...
                                                          ^
HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.


Perhaps someone can understand this and help

Regards

Richard

> > Any further help appreciated.
> >
> > Richard
>
> Rich,
>
> Unfortunately I don't know perl too well so the above is pretty cryptic
> to me too. From my cursory reading - seems the above just registers
> PostgreSQL datatypes with DBD.
>
> Which language are you programming in?  My default encoding for my
> database is UTF-8, but I don't recall having to do anything special that
> wasn't already implicitly done by the driver I was using and I think the
> npgsql ADO.NET driver already takes care of registering the Pg bytea and
> other PG specific data types so my guess is you are not using .NET.
> Then again I don't do too much of storing images in the database.
>
> Seems then that whatever you are doing is not translating your data to
> bytea format correctly.
>
> Hope that helps,
> Regina
>
>
>
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.

Re: How to save a image file in a postgres data field.

От
"Sean Davis"
Дата:
On Wed, Sep 3, 2008 at 6:52 AM, Sean Davis <sdavis2@mail.nih.gov> wrote:
> On Wed, Sep 3, 2008 at 3:08 AM, richard terry <rterry@gnumed.net> wrote:
>> On Tue, 2 Sep 2008 10:40:59 pm Obe, Regina wrote:
>>> > =============================================
>>> > Hear your pain, this was all done on debian linux. binmode was a
>>>
>>> gotcha
>>>
>>> > I've done it with a bytea column like this
>>> >
>>> > use DBI ;
>>> > use DBD::Pg qw(:pg_types); #Required for us to use the *bytea* column
>>>
>>> =============================================
>>>
>>> > I can't interpet the last line which (admittedly in another language)
>>>
>>> he says
>>>
>>> > is needed to use the bytea type.
>>> >
>> I've made a little progress with some help from a gambas user but still
>> failing. Perhaps these two sample queries which stall will prompt someone to
>> guide me in the correct direction:
>
>> HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
>
> The hint is probably helpful.  See here:
>
> http://archives.postgresql.org/pgsql-jdbc/2005-10/msg00007.php
> http://www.postgresql.org/docs/8.3/static/datatype-binary.html
>
> Both the documentation and the mailing lists are searchable, just in
> case you need more detail.
>
> Hope that helps,
> Sean
>
>>
>>> > Any further help appreciated.
>>> >
>>> > Richard
>>>
>>> Rich,
>>>
>>> Unfortunately I don't know perl too well so the above is pretty cryptic
>>> to me too. From my cursory reading - seems the above just registers
>>> PostgreSQL datatypes with DBD.
>>>
>>> Which language are you programming in?  My default encoding for my
>>> database is UTF-8, but I don't recall having to do anything special that
>>> wasn't already implicitly done by the driver I was using and I think the
>>> npgsql ADO.NET driver already takes care of registering the Pg bytea and
>>> other PG specific data types so my guess is you are not using .NET.
>>> Then again I don't do too much of storing images in the database.
>>>
>>> Seems then that whatever you are doing is not translating your data to
>>> bytea format correctly.
>>>
>>> Hope that helps,
>>> Regina
>>>
>>>
>>>
>>> -----------------------------------------
>>> The substance of this message, including any attachments, may be
>>> confidential, legally privileged and/or exempt from disclosure
>>> pursuant to Massachusetts law. It is intended
>>> solely for the addressee. If you received this in error, please
>>> contact the sender and delete the material from any computer.
>>
>> --
>> Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-novice
>>
>

Re: How to save a image file in a postgres data field.

От
Syan Tan
Дата:
http://www.postgresql.org/docs/8.3/interactive/datatype-binary.html

seems like you have to manually iterate the byte array and convert to octal for
any byte that is
\ , ' ,  0-31 , and 127-255  .  Apparently there is two escape parsings , so you
need double backslash
to

alternatively, try the code in

http://forum.stormweb.no/index.php?topic=330.0

which is base64 encoding / decoding for gambas.

python has a built in module for base64, which I used to convert binary image data
into printable text, and stored the image data in ordinary postgresql text fields.

Actually, I tried insert into a_table (img_field) values ( E'<your string>' )
and it worked in pgadmin III

insert into
testimage(img) values

(E'\\211PNG\\015\\012\\032\\012\\000\\000\\000\\015IHDR\\000\\000\\000\\232\\000\\000\\000\\311\\010\\002\\000\\000\\000T\\207\\274\\031\\000\\000\\005\\266IDATx\\234\\355\\235\\331\\266\\2330\\020\\004\\345\\234\\374\\377/\\223\\007\\345\\020\\007\\373\\012!f\\351i\\272\\236\\262\\330
M1#!\\263\\274\\266mk\\202\\205_\\331\\015\\020\\226H\'\\025\\322I\\205tR!
\\235TH\'\\025\\322I\\205tR\\361;\\273\\001f\\274^/\\333\\015V\\134`!
\\311Ns\\227N\\333\\364\\206A\\247_\\334\\313\\031e\\320)v\\244\\223\\212\\362:
\\313\\325CW\\312\\353\\364\\246\\326\\341R[g\\255X\\007P\\370\\274s\\354\\362\\352Y#\\307\\221Q5;
\\265h\\360\\225\\252:
\\307\\330\\272)\\224\\270%u\\026\\212o0\\365t\\236\\272\\344
(\\233k\\024\\323\\351\\352r\\360\\335*\\365\\240\\222N\\345\\345)5NT\\252$G:

\\005\\262s\\322\\245wj\\2268\\244\\320u\\006\\273\\254^\\256\\241u\\202\\344e!puf\\271,=\\277\\005\\325\\251\\274\\134\\003T\\347\\014r\\371\\311\\0130
(\\010\\347\\227\\2036\\000Fl\\007.;

\\021\\134\\216A\\036A\\341t\\216Iw\\011\\016\\226N\\333_\\244\\3570\\336\\027l\\202\\002\\351\\204\\215Q!Pt\\002\\016\\231\\025\\023\\024B\'\\240\\313\\242\\344\\353DvY\\3560J\\326\\211Y\\262&\\001l|

\\246\\316\\231p\\244\\347G\\255\\0214\\277\\330\\016Hw9\\003\\224\\3214\\235\\310C\\346\\001\\234\\226\\234\\002\\232\\235h\\021\\254Rrst\\342\\254\\376\\314S\\302h\\202N\\220\\236\\233\\203\\320\\257h\\235\\205\\206\\314ON\\333\\226n\\024t\\354\\024k\\204\\352,
\\235\\232\\035\\360\\004\\005\\312N|\\227\\035d\\243q:+\\316f\\177\\002\\326
(Pv\\326b\\306h\\274\\324 \\235L\\251y\\211`\\243\\021:

\\323\\247\\357NL\\036\\205\\221\\335w\\327I0\\233\\375J\\357\\327\\274\\321\\030\\251\\276:Y]\\2763\\337\\205\\000\\243\\216:

\\237\\340\\262\\263m\\033H\\232z\\335\\256\\313:^\\016\\330\\266m\\262\\327~\\301\\261\\327Y\\372n\\241\\367\\306/\\264p\\336\\350\\362.
\\306\\030\\337\\243R\\335\\345
{\\303\\016\\177}\\377w\\303\\235\\332\\206\\302,;
\\347;Y\\302\\345\\347\\377\\356\\177\\356\\037\\033\\177\\276M\\007\\344\\322\\014\\371|
k&\\033"p\\331\\377\\260\\253:|\\340\\263\\331\\247:
\\277ng\\200\\215\\210\\233

[\\311\\035*L\\370I\\336i\\276\\316tg\\2412\\337\\211\\322\\255b[\\327\\345\\370\\366\\315IUw\\3662\\376\\326\\362\\336o|
\\263\\254\\313w\\356\\334\\226
{(\\321\\2276~\\312Z\\304Vtr\\210\\334\\371\\251;
\\313\\313=\\373\\027o\\316\\201\\027Bw\\241\\330>pe`\\222C\\334\\255\\002\\265Pug\\277\\020_7b\\350!;

\\234-\\344\\216\\235\\357\\134m\\306Tv\\336l\\226Ut\\3748\\234\\237\\200\\267v\\200\\256F\\370G\\267\\030\\340r~\\311\\376*\\226k\\266WW,

\\021x\\257\\264\\301U\\344\\260\\240h\\262M3\\235\\247+^\\260\\025lr\\321\\316\\273\\015_\\247\\307W\\357\\231\\234\\3229N;XO\\227H\\357\\305\\327\\006\\134]x\\232\\315\\316\\257F\\323C\\200L\\330\\270s9;?
\\2776\\370L\\271\\341\\223\\011\\315l\\251@\\271\\012\\3769\\270\\216P\\312N\\027tS\\2030\\300^\\247\\246\\273\\211
(;

\\355ISP\\2615#\\275\\3226\\351$\\303Q\\247\\352m<9\\2572\\017\\270l\\356\\346m\\361\\206D\\356\\235\\263\\330\\036\\206\\261\\347\\314\\245\\011u~\\225\\367\\020\\243\\276:5|
\\006C\\230\\235OF:\\251 \\324\\271|

w\\000\\001\\270o9\\272\\303A\\336C\\134\\266\\254\\363\\316\\000\\202\\025\\202\\314\\234\\011\\213\\355\\223q\\327\\371\\234B\\207\\200\\262\\323\\227\\340\\243Y:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251p\\327\\011\\362\\014\\210\\207\\240\\354\\244B:

\\251H\\323\\251\'\\232x\\340\\253S\\003gp\\004Tl\\251p\\324\\251\\324\\214\\307\\345\\231\\354\\247")\\007N\\316\\027o()\\0231\\3269\\343\\22225\\307\\204\\035\\342\\232\\012Q!
\\235A\\304$\\250\\336\\020H\\205\\261\\316\\311qQF\\235\\340|

\\026\\374c\\261\\3279?q}\\275^LR\\021f\\354\\371\\2572\\227QCB\\337\\3247&=\\026\\367\\031w6\\240\\203@\\217\\366\\257^{\\021\\032\\357\\236\\235\\177ws\\261\\253\\2652u\\262w\\014\\331\\331\\331\\266\\215u@\\205jj\\350\\211\\012\\237Q\\264\\231AP\\261\\375o\\227W<\\301V]\\314^$\\350l\\250\\261\\230\\007-)wrt\\266\\262F\\301\\233\\235\\246\\363_\\013`\\246\\205\\247\\200\\273l\\010:
[\\005\\243\\370";\\020:;\\200W2,

\\314\\256s\\343\\011\\244\\263\\201\\031\\255\\270\\364\\201\\245\\263\\223~!`\\271\\244\\334)\\371\\262\\344\\036\\356\\224KJ?
\\001\\021\\331A\\274V(\\353\\222\\206\\352.
\\033f\\261\\355\\204\\235\\252\\257\\035\\026\\230q\\303\\325\\331\\374O\\017\\226\\363\\0336h\\320:
\\233\\233Q>\\221\\035t\\235\\315\\324

(\\253\\305\\035\\304\\251\\320\\001\\253\\237\\325\\350]\\266\\022\\331\\271\\263<9z\\202\\310N%\\235\\235KR\\237#\\262SOg\\363\\277P\\241bL:
%uv\\314\\245\\326\\015\\305Na\\235\\315\\316h\\351
\\274S[g\\273m\\264z\\367\\017\\224\\327\\331\\270V\\351n\\302\\240\\263\\325\\271Z\\300\\233\\222?
\\220-C,
\\262C\\222\\235\\015\\340v\\037\\004xt\\266\\037\\2142u\\360\\024*\\235\\242\\300\\022\\274\\230G:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\220N*\\244\\223\\012\\351\\244B:
\\251\\370\\003>\\241\\324n\\304~\\303\\331\\000\\000\\000\\000IEND\\256B`\\202')



On Wed  3/09/08 07:08 , richard terry rterry@gnumed.net sent:
> On Tue, 2 Sep 2008 10:40:59 pm Obe, Regina wrote:
> > >
> =============================================> > Hear your pain, this was all
done on debian
> linux. binmode was a>
> > gotcha
> >
> > > I've done it with a bytea column like
> this> >
> > > use DBI ;
> > > use DBD::Pg qw(:pg_types); #Required for us to
> use the *bytea* column>
> >
> =============================================>
> > > I can't interpet the last line which (admittedly
> in another language)>
> > he says
> >
> > > is needed to use the bytea type.
> > >
> I've made a little progress with some help from a gambas user but still
> failing. Perhaps these two sample queries which stall will prompt someone
> to guide me in the correct direction:
>
> On Tue, 2 Sep 2008 09:48:55 pm you wrote:
> Ok, that got me a bit further: This is the resultant (failed) insert query
> .First try using $$ as the delimiters as per my code gives this and
> fails:
> insert into
> clin_consult.temp_image(piccie)values($$\\211PNG\\015\\012\\032\\012\\000\\
> 000\\000\\015IHDR\\000\\000\\000\\232\\000\\000\\000\\311\\010\\002\\000\\0
> 00\\000T\\207\\274\\031\\000\\000\\005\\266IDATx\\234\\355\\235\\331\\266\\
> 2330\\020\\004\\345\\234\\374\\377/\\223\\007\\345\\020\\007\\373\\012!f\\3
> 51i\\272\\236\\262\\330

M1#!\\263\\274\\266mk\\202\\205_\\331\\015\\020\\226H\'\\025\\322I\\205tR!\\235TH\'\\025\\322I\\205tR\\361;\\273\\001f\\274^/\\333\\015V\\134`!
> \\311Ns\\227N\\333\\364\\206A\\247_\\334\\313\\031e\\320)v\\244\\223\\212\\
> 362:\\313\\325CW\\312\\353\\364\\246\\326\\341R[g\\255X\\007P\\370\\274s\\354\\
> 362\\352Y#\\307\\221Q5;\\265h\\360\\225\\252:
> \\307\\330\\272)\\224\\270%u\\026\\212o0\\365t\\236\\272\\344
> (\\233k\\024\\323\\351\\352r\\360\\335*\\365\\240\\222N\\345\\345)5NT\\252$
> G:\\005\\262s\\322\\245wj\\2268\\244\\320u\\006\\273\\254^\\256\\241u\\202\\3
> 44e!puf\\271,=\\277\\005\\325\\251\\274\\134\\003T\\347\\014r\\371\\311\\01
> 30(\\010\\347\\227\\2036\\000Fl\\007.;
> \\021\\134\\216A\\036A\\341t\\216Iw\\011\\016\\226N\\333_\\244\\3570\\336\\
> 027l\\202\\002\\351\\204\\215Q!Pt\\002\\016\\231\\025\\023\\024B\'\\240\\31
>

3\\242\\344\\353DvY\\3560J\\326\\211Y\\262&\\001l|\\246\\316\\231p\\244\\347G\\255\\0214\\277\\330\\016Hw9\\003\\224\\3214\\2
> 35\\310C\\346\\001\\234\\226\\234\\002\\232\\235h\\021\\254Rrst\\342\\254\\
> 376\\314S\\302h\\202N\\220\\236\\233\\203\\320\\257h\\235\\205\\206\\314ON\
>
\333\\226n\\024t\\354\\024k\\204\\352,\\235\\232\\035\\360\\004\\005\\312N|\\227\\035d\\243q:+\\316f\\177\\002\\3
> 26(Pv\\326b\\306h\\274\\324 \\235L\\251y\\211`\\243\\021:
> \\323\\247\\357NL\\036\\205\\221\\335w\\327I0\\233\\375J\\357\\327\\274\\32
>

1\\030\\251\\276:Y]\\2763\\337\\205\\000\\243\\216:\\237\\340\\262\\263m\\033H\\232z\\335\\256\\313:^\\016\\330\\266m\\262\\32
>
7~\\301\\261\\327Y\\372n\\241\\367\\306/\\264p\\336\\350\\362.\\306\\030\\337\\243R\\335\\345
> {\\303\\016\\177}\\377w\\303\\235\\332\\206\\302,;
> \\347;Y\\302\\345\\347\\377\\356\\177\\356\\037\\033\\177\\276M\\007\\344\\
> 322\\014\\371|k&\\033"p\\331\\377\\260\\253:|\\340\\263\\331\\247:
> \\277ng\\200\\215\\210\\233
> [\\311\\035*L\\370I\\336i\\276\\316tg\\2412\\337\\211\\322\\255b[\\327\\345
> \\370\\366\\315IUw\\3662\\376\\326\\362\\336o|\\263\\254\\313w\\356\\334\\226
> {(\\321\\2276~\\312Z\\304Vtr\\210\\334\\371\\251;
> \\313\\313=\\373\\027o\\316\\201\\027Bw\\241\\330>pe`\\222C\\334\\255\\002\
>
\265Pug\\277\\020_7b\\350!;\\234-\\344\\216\\235\\357\\134m\\306Tv\\336l\\226Ut\\3748\\234\\237\\200\\
>

267v\\200\\256F\\370G\\267\\030\\340r~\\311\\376*\\226k\\266WW,\\021x\\257\\264\\301U\\344\\260\\240h\\262M3\\235\\247+^\\260\\025lr\\321\
> \316\\273\\015_\\247\\307W\\357\\231\\234\\3229N;XO\\227H\\357\\305\\327\\0
>

06\\134]x\\232\\315\\316\\257F\\323C\\200L\\330\\270s9;?\\2776\\370L\\271\\341\\223\\011\\315l\\251@\\271\\012\\3769\\270\\216P\\31
> 2N\\027tS\\2030\\300^\\247\\246\\273\\211(;
> \\355ISP\\2615#\\275\\3226\\351$\\303Q\\247\\352m\\006C\\230\\235OF:\\251
\\324\\271|
> w\\000\\001\\270o9\\272\\303A\\336C\\134\\266\\254\\363\\316\\000\\202\\025
> \\202\\314\\234\\011\\213\\355\\223q\\327\\371\\234B\\207\\200\\262\\323\\2
> 27\\340\\243Y:\\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251p\\327\\011\\362\\014\\210\\207\\240\\354\\244B:
> \\251H\\323\\251\'\\232x\\340\\253S\\003gp\\004Tl\\251p\\324\\251\\324\\214
> \\307\\345\\231\\354\\247")\\007N\\316\\027o()\\0231\\3269\\343\\22225\\307
>
\\204\\035\\342\\232\\012Q!\\235A\\304$\\250\\336\\020H\\205\\261\\316\\311qQF\\235\\340|
> \\026\\374c\\261\\3279?q}\\275^LR\\021f\\354\\371\\2572\\227QCB\\337\\3247&
> =\\026\\367\\031w6\\240\\203@\\217\\366\\257^{\\021\\032\\357\\236\\235\\17
> 7ws\\261\\253\\2652u\\262w\\014\\331\\331\\331\\266\\215u@\\205jj\\350\\211
> \\012\\237Q\\264\\231AP\\261\\375o\\227W[\\005\\243\\370";\\020:;\\200W2,
> \\314\\256s\\343\\011\\244\\263\\201\\031\\255\\270\\364\\201\\245\\263\\22
>
3~!`\\271\\244\\334)\\371\\262\\344\\036\\356\\224KJ?\\001\\021\\331A\\274V(\\353\\222\\206\\352.
> \\033f\\261\\355\\204\\235\\252\\257\\035\\026\\230q\\303\\325\\331\\374O\\
> 017\\226\\363\\0336h\\320:\\233\\233Q>\\221\\035t\\235\\315\\324
> (\\253\\305\\035\\304\\251\\320\\001\\253\\237\\325\\350]\\266\\022\\331\\2
> 71\\263%uv\\314\\245\\326\\015\\305Na\\235\\315\\316h\\351
> \\274S[g\\273m\\264z\\367\\017\\224\\327\\331\\270V\\351n\\302\\240\\263\\3
> 25\\271Z\\300\\233\\222?\\220-C,
> \\262C\\222\\235\\015\\340v\\037\\004xt\\266\\037\\2142u\\360\\024*\\235\\2
> 42\\300\\022\\274\\230G:\\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\370\\003>\\241\\324n\\304~\\303\\331\\000\\000\\000\\000IEND\\256B`\
> \202$$)
> Second try using ' as delimeters gives this and fails, but adds a hint:
>
> insert into
> clin_consult.temp_image(piccie)values('\\211PNG\\015\\012\\032\\012\\000\\0
> 00\\000\\015IHDR\\000\\000\\000\\232\\000\\000\\000\\311\\010\\002\\000\\00
> 0\\000T\\207\\274\\031\\000\\000\\005\\266IDATx\\234\\355\\235\\331\\266\\2
> 330\\020\\004\\345\\234\\374\\377/\\223\\007\\345\\020\\007\\373\\012!f\\35
> 1i\\272\\236\\262\\330

M1#!\\263\\274\\266mk\\202\\205_\\331\\015\\020\\226H\'\\025\\322I\\205tR!\\235TH\'\\025\\322I\\205tR\\361;\\273\\001f\\274^/\\333\\015V\\134`!
> \\311Ns\\227N\\333\\364\\206A\\247_\\334\\313\\031e\\320)v\\244\\223\\212\\
> 362:\\313\\325CW\\312\\353\\364\\246\\326\\341R[g\\255X\\007P\\370\\274s\\354\\
> 362\\352Y#\\307\\221Q5;\\265h\\360\\225\\252:
> \\307\\330\\272)\\224\\270%u\\026\\212o0\\365t\\236\\272\\344
> (\\233k\\024\\323\\351\\352r\\360\\335*\\365\\240\\222N\\345\\345)5NT\\252$
> G:\\005\\262s\\322\\245wj\\2268\\244\\320u\\006\\273\\254^\\256\\241u\\202\\3
> 44e!puf\\271,=\\277\\005\\325\\251\\274\\134\\003T\\347\\014r\\371\\311\\01
> 30(\\010\\347\\227\\2036\\000Fl\\007.;
> \\021\\134\\216A\\036A\\341t\\216Iw\\011\\016\\226N\\333_\\244\\3570\\336\\
> 027l\\202\\002\\351\\204\\215Q!Pt\\002\\016\\231\\025\\023\\024B\'\\240\\31
>

3\\242\\344\\353DvY\\3560J\\326\\211Y\\262&\\001l|\\246\\316\\231p\\244\\347G\\255\\0214\\277\\330\\016Hw9\\003\\224\\3214\\2
> 35\\310C\\346\\001\\234\\226\\234\\002\\232\\235h\\021\\254Rrst\\342\\254\\
> 376\\314S\\302h\\202N\\220\\236\\233\\203\\320\\257h\\235\\205\\206\\314ON\
>
\333\\226n\\024t\\354\\024k\\204\\352,\\235\\232\\035\\360\\004\\005\\312N|\\227\\035d\\243q:+\\316f\\177\\002\\3
> 26(Pv\\326b\\306h\\274\\324 \\235L\\251y\\211`\\243\\021:
> \\323\\247\\357NL\\036\\205\\221\\335w\\327I0\\233\\375J\\357\\327\\274\\32
>

1\\030\\251\\276:Y]\\2763\\337\\205\\000\\243\\216:\\237\\340\\262\\263m\\033H\\232z\\335\\256\\313:^\\016\\330\\266m\\262\\32
>
7~\\301\\261\\327Y\\372n\\241\\367\\306/\\264p\\336\\350\\362.\\306\\030\\337\\243R\\335\\345
> {\\303\\016\\177}\\377w\\303\\235\\332\\206\\302,;
> \\347;Y\\302\\345\\347\\377\\356\\177\\356\\037\\033\\177\\276M\\007\\344\\
> 322\\014\\371|k&\\033"p\\331\\377\\260\\253:|\\340\\263\\331\\247:
> \\277ng\\200\\215\\210\\233
> [\\311\\035*L\\370I\\336i\\276\\316tg\\2412\\337\\211\\322\\255b[\\327\\345
> \\370\\366\\315IUw\\3662\\376\\326\\362\\336o|\\263\\254\\313w\\356\\334\\226
> {(\\321\\2276~\\312Z\\304Vtr\\210\\334\\371\\251;
> \\313\\313=\\373\\027o\\316\\201\\027Bw\\241\\330>pe`\\222C\\334\\255\\002\
>
\265Pug\\277\\020_7b\\350!;\\234-\\344\\216\\235\\357\\134m\\306Tv\\336l\\226Ut\\3748\\234\\237\\200\\
>

267v\\200\\256F\\370G\\267\\030\\340r~\\311\\376*\\226k\\266WW,\\021x\\257\\264\\301U\\344\\260\\240h\\262M3\\235\\247+^\\260\\025lr\\321\
> \316\\273\\015_\\247\\307W\\357\\231\\234\\3229N;XO\\227H\\357\\305\\327\\0
>

06\\134]x\\232\\315\\316\\257F\\323C\\200L\\330\\270s9;?\\2776\\370L\\271\\341\\223\\011\\315l\\251@\\271\\012\\3769\\270\\216P\\31
> 2N\\027tS\\2030\\300^\\247\\246\\273\\211(;
> \\355ISP\\2615#\\275\\3226\\351$\\303Q\\247\\352m\\006C\\230\\235OF:\\251
\\324\\271|
> w\\000\\001\\270o9\\272\\303A\\336C\\134\\266\\254\\363\\316\\000\\202\\025
> \\202\\314\\234\\011\\213\\355\\223q\\327\\371\\234B\\207\\200\\262\\323\\2
> 27\\340\\243Y:\\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251p\\327\\011\\362\\014\\210\\207\\240\\354\\244B:
> \\251H\\323\\251\'\\232x\\340\\253S\\003gp\\004Tl\\251p\\324\\251\\324\\214
> \\307\\345\\231\\354\\247")\\007N\\316\\027o()\\0231\\3269\\343\\22225\\307
>
\\204\\035\\342\\232\\012Q!\\235A\\304$\\250\\336\\020H\\205\\261\\316\\311qQF\\235\\340|
> \\026\\374c\\261\\3279?q}\\275^LR\\021f\\354\\371\\2572\\227QCB\\337\\3247&
> =\\026\\367\\031w6\\240\\203@\\217\\366\\257^{\\021\\032\\357\\236\\235\\17
> 7ws\\261\\253\\2652u\\262w\\014\\331\\331\\331\\266\\215u@\\205jj\\350\\211
> \\012\\237Q\\264\\231AP\\261\\375o\\227W[\\005\\243\\370";\\020:;\\200W2,
> \\314\\256s\\343\\011\\244\\263\\201\\031\\255\\270\\364\\201\\245\\263\\22
>
3~!`\\271\\244\\334)\\371\\262\\344\\036\\356\\224KJ?\\001\\021\\331A\\274V(\\353\\222\\206\\352.
> \\033f\\261\\355\\204\\235\\252\\257\\035\\026\\230q\\303\\325\\331\\374O\\
> 017\\226\\363\\0336h\\320:\\233\\233Q>\\221\\035t\\235\\315\\324
> (\\253\\305\\035\\304\\251\\320\\001\\253\\237\\325\\350]\\266\\022\\331\\2
> 71\\263%uv\\314\\245\\326\\015\\305Na\\235\\315\\316h\\351
> \\274S[g\\273m\\264z\\367\\017\\224\\327\\331\\270V\\351n\\302\\240\\263\\3
> 25\\271Z\\300\\233\\222?\\220-C,
> \\262C\\222\\235\\015\\340v\\037\\004xt\\266\\037\\2142u\\360\\024*\\235\\2
> 42\\300\\022\\274\\230G:\\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\220N*\\244\\223\\012\\351\\244B:
> \\251\\370\\003>\\241\\324n\\304~\\303\\331\\000\\000\\000\\000IEND\\256B`\
> \202')WARNING:  nonstandard use of \\ in a string literal
> LINE 1: insert into clin_consult.temp_image(piccie)values('\\211PNG\...
>                                                  
>         ^HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
>
>
> Perhaps someone can understand this and help
>
> Regards
>
> Richard
>
> > > Any further help appreciated.
> > >
> > > Richard
> >
> > Rich,
> >
> > Unfortunately I don't know perl too well so the
> above is pretty cryptic> to me too. From my cursory reading - seems the
> above just registers> PostgreSQL datatypes with DBD.
> >
> > Which language are you programming in?  My default
> encoding for my> database is UTF-8, but I don't recall having to do
> anything special that> wasn't already implicitly done by the driver I was
> using and I think the> npgsql ADO.NET driver already takes care of
> registering the Pg bytea and> other PG specific data types so my guess is you are
> not using .NET.> Then again I don't do too much of storing images in
> the database.>
> > Seems then that whatever you are doing is not
> translating your data to> bytea format correctly.
> >
> > Hope that helps,
> > Regina
> >
> >
> >
> >
> -----------------------------------------> The substance of this message,
including any
> attachments, may be> confidential, legally privileged and/or exempt from
> disclosure> pursuant to Massachusetts law. It is
> intended> solely for the addressee. If you received this in
> error, please> contact the sender and delete the material from any
> computer.
> --
> Sent via pgsql-novice mailing list (p
> gsql-novice@postgresql.org)To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
>