Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DBeaver import csv empty string as NULL is not working

I have the following table prop_info which has foreign key reference to desp. I am trying to import csv file which has these

prop_code,prop_name,price
ABC,,1.2,
ABB,Apple,5.0,

CREATE TABLE prop_info (
 prop_code CHAR (3) PRIMARY KEY  NOT NULL,
 prop_name VARCHAR (100) REFERENCES desp (product_name) ON UPDATE CASCADE,
 price float NOT NULL
);

CREATE TABLE desp 
(
    product_name VARCHAR (100) PRIMARY KEY  NOT NULL,
    product_desp VARCHAR (100)
);

I was trying to upload CSV using DBeaver, receiving this error:

ERROR: insert or update on table "prop_info" violates foreign key constraint "prop_info_prop_name_fkey"
Detail: Key (prop_name)=() is not present in table "desp".

As per the PostgreSQL, I do have unquoted empty string.

Specifies the string that represents a null value. The default is \N (backslash-N) in text format, and an unquoted empty string in CSV format. You might prefer an empty string even in text format for cases where you don't want to distinguish nulls from empty strings. This option is not allowed when using binary format.

is this a issue with my DBeaver? Need help.

like image 889
as - if Avatar asked Oct 17 '25 04:10

as - if


2 Answers

There is an option Set empty strings to NULL which worked for me in DBeaver 21.3.4 Community Edition

enter image description here

like image 103
Robert Niestroj Avatar answered Oct 19 '25 21:10

Robert Niestroj


In DBeaver 24.3.1.2024 Community Edition, you can archive that by setting value for an option "NULL value mark" is NULL enter image description here

like image 43
nguyen Avatar answered Oct 19 '25 21:10

nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!