Questions tagged [bytea]

Variable-length binary string type in PostgreSQL

155 questions
49
votes
2 answers

Are there performance issues storing files in PostgreSQL?

Is ok storing files like HTML pages, images, PDF, etc in a table in PostgreSQL or it is slow? I read some articles saying that this is not recommended, but I don't know if is true. The column types I have in mind are BLOB (as far as I know it stores…
Renato Dinhani
  • 30,005
  • 49
  • 125
  • 194
40
votes
2 answers

What is the datatype bytea and when would I use it?

In Postgres there is a datatype called bytea The Postgres docs are here for it: http://www.postgresql.org/docs/9.0/static/datatype-binary.html I cannot understand when I would ever use this - nor can I really understand the purpose of this…
Walker Farrow
  • 2,859
  • 4
  • 26
  • 50
14
votes
5 answers

How to save a image file on a Postgres database?

For learning purposes, I'm creating a site using Python+Flask. I want to recover an image from database and show it on screen. But one step at a time. I have no idea how to save an image in my database in the first place. My searches only revealed…
Felipe Matos
  • 155
  • 1
  • 1
  • 9
12
votes
5 answers

How to read bytea image data from PostgreSQL with JPA?

I have PostgreSQL database and there is column 'image' with datatype 'bytea'. I cannot modify columns or database configurations. JPA annotated POJO contains followign mapping @Column(name="image") private byte[] image; The returned data is in…
Bhushan
  • 537
  • 1
  • 5
  • 14
10
votes
3 answers

Convert PostgreSQL bytea-stored serialized-java-UUID to postgresql-UUID

One of our software-projects uses a PostgreSQL-table with a column 'guid' of type bytea. This is used with hibernate 3.3.2.GA with PostgreSQL 8.4, which serializes the java UUID type using java object serialization. The result is a value like the…
FvHovell
  • 131
  • 1
  • 5
7
votes
1 answer

Convert bytea to double precision in PostgreSQL

I have a database where one of the tables stores a blob (bytea) of all kinds of generic data collected from another system. The bytea field can have anything in it. In order to know how to interpret the data, the table also has a format field. I…
Keith
  • 143
  • 7
7
votes
4 answers

Storing images in bytea fields in a PostgreSQL database

I stored an image in a PostgreSQL database with column type bytea using PHP. The problem is every time I try to load the image in a browser it does not appear. The Firefox developer console says the image is either truncated or corrupt. The PHP…
Olayemi Odunayo
  • 83
  • 1
  • 1
  • 5
7
votes
4 answers

Convert bigint to bytea, but swap the byte order

I have a PostgreSQL table that I want to alter a column from bigint to bytea byte to hold more data. I am thinking using the following sequence: alter table mytable add new_column update mytable set new_column = int8send(old_column) alter table…
Junping
  • 569
  • 6
  • 8
5
votes
2 answers

Convert a bytea into a binary string

I need to decode a base64 string and take a chunk of binary. Is there a SQL function in Postgres to simply convert a bytea into a binary string representation? (Like "00010001010101010".)
GPif
  • 453
  • 4
  • 16
5
votes
1 answer

Proper way to convert bytea from Postgres back to a string in python

I have a small script where I'm generating SHA1 hashes, taking the binary representation through hashlib's hexdigest, and storing them in a Postgres DB with a bytea column. I have a query that looks like this in Postgres (abbreviated): SELECT * FROM…
Clicquot the Dog
  • 468
  • 1
  • 6
  • 16
5
votes
0 answers

Postgres. How to convert string that contains '\' to bytea?

I have string 'test\data' or just one backslash symbol '\'. How it convert to bytea?
marvinorez
  • 543
  • 3
  • 7
5
votes
1 answer

PostgreSQL 9.X bytea representation in 'hex' or 'escape' for thumbnail images

My application (developed in Delphi and ZEOS components) uses PostgreSQL 8.4 and stores some thumbnail images into a bytea column. I want to migrate to PostgreSQL 9.2 and have restored the dump and everything works fine except when I try to retrieve…
AndreaBoc
  • 2,471
  • 2
  • 13
  • 20
5
votes
2 answers

Store and retrieve images in Postgresql using Java

I am new to Java programming, I am searching for Java code to store images in PostgreSQL and to retrieve the image. In PostgreSQL I have used Bytea Data-type. the image was stored. but when I retrieve I am getting NULL. I cant get the image. Any…
MAHI
  • 7,205
  • 10
  • 34
  • 46
5
votes
1 answer

PostgreSQL replication with rubyrep

I'm new to rubyrep and currently using rubyrep-1.2.0 version for PostgreSQL Master-Master replication. All data types except bytea are getting replicated properly. While replicating bytea column, it seems like the data is escaped twice. I'm using…
5
votes
5 answers

Convert a bytea column to OID while retaining values

I'm trying to alter a bytea column to have type oid and still retain the values. I have tried using queries like: ALTER TABLE mytable ADD COLUMN mycol_tmp oid; UPDATE mytable SET mycol_tmp = CAST(mycol as oid); ALTER TABLE mytable DROP COLUMN…
Petter
  • 3,843
  • 23
  • 31
1
2 3
10 11