Search Postgresql Archives

Re: Import file into bytea field in SQL/plpgsql?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Erwin Brandstetter wrote:
Hi!

What I want to do:
Import a file from the file system into a bytea field of a table.

Now, I could copy over from pg_largeobject:

And create a large object and export from there as above.
But that seems unnecessarily complex, and  .. well .. stupid.

There must be a simpler way to import/export a file (as a whole, an
image for instance) into/out of my bytea field - in SQL or plpgsql?
Probably another set of functions I overlooked?

Not that I know of. It's simple enough to do from the application side of things of course (well, in most languages) but there's no general file access.

You can do various tricks to grab text values (see psql in the docs "SQL Interpolation") but you'd need to escape the values. Not sure that's any cleaner than the large-object approach.

--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux