Questions tagged [bytea]

Variable-length binary string type in PostgreSQL

155 questions
4
votes
0 answers

How convert bytea in timestamp?

I have an entity with a property of type java.time.Instant. @ApiModelProperty(required = false) private Instant date; I am using PostgreSQL and this column was converted to bytea. The hibernate show in the console a query like this: select…
Luciano Borges
  • 673
  • 2
  • 9
  • 26
4
votes
2 answers

Alphanumeric Sorting in PostgreSQL

I have this table with a character varying column in Postgres 9.6: id | column ------------ 1 |IR ABC-1 2 |IR ABC-2 3 |IR ABC-10 I see some solutions typecasting the column as bytea. select * from table order by column::bytea. But it always…
muffin
  • 1,832
  • 7
  • 37
  • 75
4
votes
1 answer

Data storage on DB: PostgreSQL "bytea" on Server to SQLite "BLOB" on Mobile App

I want to use image storage on DB and not URL. On my server side I use PostgreSQL and I read here that "bytea" is the suggested format to use in order to store files. On my mobile app side, the DB is SQLite. It seems the data storage suggested…
nyluje
  • 3,255
  • 4
  • 30
  • 58
4
votes
2 answers

Displaying Image Stored as Binary in Postgre bytea Column

I'm stuck for hours working on this. Few solutions found over the Net but no one seems to help me. I am having problem to display an image on the browser using PHP that takes the image from Postgres DB with column type bytea. I'm sure I'm missing…
UserProg
  • 599
  • 1
  • 6
  • 21
3
votes
2 answers

PostgreSQL - How to insert Base64 images strings into a BYTEA column?

I have the following SQL: CREATE TABLE Documents ( Id INT NOT NULL, UserId INT NOT NULL, Label CHARACTER VARYING(220) NOT NULL, Image BYTEA NOT NULL, PRIMARY Key(Id), FOREIGN KEY (UserId) REFERENCES Users(Id) ); I want to know, How…
user11150028
3
votes
1 answer

PostgreSQL - How to convert current timestamp into bytea

I have migrated a database from SQL Server into PostgreSQL. A number of tables contain a ts column(timestamp) which stores the rowversion and is autogenerated in SQL server. When I converted the stored procedures into PostgreSQL, I found that…
3
votes
2 answers

PostgreSQL load images to DB

I've already know how to store images in DB, just use bytea type in my table And I've already can save images to DB via code in my project .net Core, I've just getting image by url and saving like there: using (HttpResponseMessage res = await…
Igor Cova
  • 2,074
  • 2
  • 20
  • 48
3
votes
1 answer

How to get data out of a postgres bytea column into a python variable using sqlalchemy?

I am working with the script below. If I change the script so I avoid the bytea datatype, I can easily copy data from my postgres table into a python variable. But if the data is in a bytea postgres column, I encounter a strange object called memory…
user3676943
  • 813
  • 9
  • 23
3
votes
1 answer

How to store file in postgres database using hibernate?

I am new to Hibernate. I need to store file in postgres, data type of the column is bytea. I looked around on internet for a working demo of this case, however I couldn't find any. Hibernate mapping :
Ketu
  • 1,230
  • 2
  • 9
  • 24
3
votes
1 answer

How to download bytea column as file using Java

I want to download files stored in bytea format using java. I don't have superuser privileges. Using the code below I download the hex encoded file and convert it to pdf but the converted pdf is damaged whereas if I copy using \copy function(cannot…
sourabh
  • 43
  • 2
  • 5
3
votes
1 answer

Golang+Postgres WHERE clause with a hex value

I created a simple sql database with a BYTEA field, create table testhex (testhex bytea); insert into testhex (testhex) values ('\x123456'); and then I tried to query it from Go. package main import ( "database/sql" _…
Nick Retallack
  • 17,432
  • 17
  • 85
  • 110
3
votes
1 answer

How to store byte from Java into a bytea in PostgreSQL?

I am getting a problem when I try to insert a variable of type "byte" in Java into a variable of type "bytea" in PostgreSQL. This is my table in postgresql: CREATE TABLE mesa ( id_mesa serial PRIMARY KEY, tag …
renatogbp
  • 534
  • 1
  • 7
  • 17
3
votes
2 answers

Retrieving file from bytea in PostgreSQL using java

Hi I'm using the below code to retrieve the file from the postgresql bytea using java, but inside the file I'm getting numbers like 314530413142313141 File file = new File("c:/test.doc"); FileOutputStream fos = new…
Sathish
  • 3,635
  • 6
  • 23
  • 52
2
votes
1 answer

Does Postgres store bytea data as hex on the server?

To work with bytea values in PostgreSQL, I usually am serializing to and deserializing from hex. This seems to be the preferred way. However, what is actually stored on the PostgreSQL server? Is it hex, or the unhexed binary? The reason I care is…
CJ Cobb
  • 105
  • 4
2
votes
1 answer

How to convert Postgres bytea to base64 string

I have a base64 image that I am trying to save in a Postgres database (using Hasura). The field is of type bytea I am not sure how to save this data to the field. I tried passing data:image/png;base64,sisodjodo... to the field, and it saves it like…
Get Off My Lawn
  • 27,770
  • 29
  • 134
  • 260
1
2
3
10 11