From: | "David Johnston" <polobo(at)yahoo(dot)com> |
---|---|
To: | "'MarkB'" <avocet77(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to store and load images in PostgreSQL db? |
Date: | 2011-05-25 16:19:51 |
Message-ID: | 050c01cc1af7$938430a0$ba8c91e0$@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
It may be as simple as making sure that:
bytea_output = escape
is present in postgresql.conf
9.0 changed the default to hex
No idea on the Table/Query aspect but at least in JDBC query parameters are
generic (i.e., "?") and you tell the API what type of value is being sent -
letting the API do the appropriate conversions. Occasionally putting an
explicit cast on the parameter (i.e., ?::int) can be handy if you are
dealing with, say, strings in code but the parameter needs to be something
else.
If necessary you could decode your image into some textual representation
and then encode into back into binary once it is in the server (using
appropriate PostgreSQL functions).
David J.
> (PSQLTable1 is on the form.)
> This works fine until the Post procedure is called. A db error near "\"
> appears.
>
> Instead of using a table I would rather use a Query, but I can't get to
work
> that at all.
>
> Query := TPSQLQuery.Create(nil);
> Query.DataBase := Db;
> BlobField := TBlobField.Create(nil);
> try
> BlobField.LoadFromFile('picture.bmp');
> Query.SQL.Text := Format ('insert into "tblImage" ("Picture_Bytea")
values
> (%s)', [QuotedStr(BlobField.Value)]);
> Query.Open;
> finally
> Query.Free;
> BlobField.Free;
> end;
>
> Apparantly it is not allowed to create a TBlobField this way and I don't
think
> it's a good idea to format a bytea-field as a string (%s) either.
>
> Sorry for my newbie question. I hope someone will be able to point me in
> the right direction to get this working as I have been searching all over
the
> internet, but have not been able to find a solution. Even finding a
correct
> forum to post this question is difficult as there does not seem to be a
> PostgreSQL forum for Delphi users.
>
> Thanks in advance!
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/How-to-store-and-load-images-
> in-PostgreSQL-db-tp4424778p4424778.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org) To make
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
From | Date | Subject | |
---|---|---|---|
Next Message | Ben Chobot | 2011-05-25 16:31:23 | temp files getting me down |
Previous Message | Geoffrey Becker | 2011-05-25 13:49:11 | Connecting to Postgres using Windows 7 |