Questions tagged [bytea]

Variable-length binary string type in PostgreSQL

189 questions
1
vote
1 answer

PostgreSQL bytea to Base64 like SQL Server

In SQL Server I convert binary to Base64 like this SELECT HASHBYTES('MD5', 'Test') FOR XML PATH(''), TYPE and have result "DLxmEfVUC9CAmjiNyVphWw==". In PostgreSQL i have SELECT encode(md5('Test')::bytea, 'base64') and result is…
Alex Petrachuk
  • 498
  • 4
  • 10
1
vote
1 answer

PostgreSQL: manipulate binary data - change last byte with SQL command

In a PostgreSQL table I have a column file_bytes which has the data type bytea. I am looking for a simple SQL statement to manipulate only the last byte of the content of this column.
André
  • 464
  • 4
  • 17
1
vote
0 answers

LocalDateTime turning into bytea with a StoredProcedureQuery

Using Java 8, Spring 4.3.9 and a Postgre database. I have a stored function defined as followed : CREATE OR REPLACE FUNCTION public.getinformations ( IN stateId integer, IN dateStart timestamp, IN dateEnd timestamp ) RETURNS SETOF…
Matthieu Durand
  • 107
  • 2
  • 10
1
vote
1 answer

Insert image into postgres database using queries

I am wondering how to insert an image into a postgres database in column of type bytea, do I have to insert from the path of the PGDATA? Thanks
Khaled
  • 13
  • 1
  • 5
1
vote
0 answers

Storing result convert.FromBase64String into postgres bytea

I have a mini system where frontend will pass the file in base64 format to the backend. I used convert.frombase64string in order for me to convert the base64 format into byte array and used file stream to save the file into the server. The codes are…
Dave Cruise
  • 443
  • 7
  • 16
1
vote
1 answer

How to decode PostgreSQL bytea column hex to int16/uint16 in r?

I have some image data stored in a PostgreSQL database table column as bytea. I also have metadata about the data for use in interpreting it, relevant ones being image dimensions and class. Classes include int16, uint16. I cannot find any…
Brian D
  • 2,570
  • 1
  • 24
  • 43
1
vote
1 answer

Different result formats when insert postgreSQL function result between JDBC & console

In postgreSQL, I use pgcrypto module to call pgp_sym_encrypt function (return bytea type) and save the result into a text column: For example I have test table with column columnA(text): CREATE EXTENSION pgcrypto; insert into test (columnA) values…
yelliver
  • 5,648
  • 5
  • 34
  • 65
1
vote
1 answer

FireDAC: How to avoid "Cannot describe type" error? (on a postgres geometry column)

I have read in the documentation (http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Defining_Connection_(FireDAC)) that one must set the connection parameter "UnknownFormat" to "BYTEA", to avoid this error. However, I have set that parameter and…
Reinier
  • 459
  • 2
  • 4
  • 13
1
vote
0 answers

Can I update a slice of bytea field parallelly in postgresql 9.6.5?

I have a table which is event_id BIGINT NOT NULL, data BYTEA and a column in this table is event_id | data ----------+-------------------- 2 | \x0000000000000000 Now, I want to update a slice of data like UPDATE "bin_data" SET…
fuxiuyin
  • 151
  • 1
  • 10
1
vote
1 answer

How to store folder in PostgreSQL

We have a requirement where we need to store mail templates in databases. these mail templates use some images. So we are thinking about storing a folder with images and HTML file in the database. The folder will have 200-300 kb of storage and we…
YogeshR
  • 1,606
  • 2
  • 22
  • 43
1
vote
1 answer

Convert SQL blob/bytea in dump to string in Python

I have a pg_dump of a table that contains a column of type bytea. It is a long string like: \\x4e696365206d7573696361... Normally in SQL I would use a simple: SELECT user_id, encode(text_column::bytea, 'escape') FROM posts LIMIT 10 And that…
LittleBobbyTables
  • 4,361
  • 9
  • 38
  • 67
1
vote
1 answer

ERROR: column "publish_date" is of type date but expression is of type bytea

I'm trying to insert objects of type Book into a database, and one of the columns is specified as date, but according to this exception: Caused by: org.postgresql.util.PSQLException: ERROR: column "publish_date" is of type date but expression is of…
1
vote
2 answers

How to generate a random 6-digit integer that's cryptographically strong?

We want a function that given an argument that is three bytes of type bytea (generated by the function gen_random_bytes of the pgcrypto extension), the function returns a random 6-digit integer (between 0 & 999999 inclusive). The 6-digit integer…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
1
vote
1 answer

Insert And Retrieve Image from PostgreSQL bytea using PDO

Im working usign PDO and PHP. This is my table in Postgre CREATE TABLE public.img ( id integer NOT NULL DEFAULT nextval('img_id_seq'::regclass), nombre bytea ) When i store the file data i use this method
Luis Cardoza Bird
  • 1,265
  • 4
  • 24
  • 43
1
vote
2 answers

JAVA JDBC Driver PostgreSQL: Parse numbers encoded as BYTEA object

I have relation where for each record there is BYTEA column (UTF-8) encoding 3 numbers in the following order: bytes 0-1: number 1 bytes 2-3: number 2 bytes 4-6: number 3 How can I parse the binary data to readable numbers? Currently I have this and…
michael
  • 3,835
  • 14
  • 53
  • 90