Super Richman

02/05/2023, 10:29 AM
Hi again :] I am trying to save a binary file to QDB from C#, is there any code example on how to do it? I have created a table with data type binary but now I don't know how to insert / select from it ;[


02/05/2023, 12:22 PM
@Super Richman you can use the ilp library: This works in NET core.

Alex Pelagenko

02/05/2023, 1:41 PM
Binary type support is limited, mostly for embedded dB use. Only pgwire has support of writing binary values up to a certain configured length

Super Richman

02/06/2023, 5:41 PM
It seems that the solution was to use MemoryStream and this:
using (var command = new NpgsqlCommand("INSERT INTO binary_data VALUES (2,@data)", connection))
                        command.Parameters.Add("@data", NpgsqlTypes.NpgsqlDbType.Bytea).Value = ReadFully(stream);
But I still haven't check that it is readable from db 😜
ok it works