question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PostgreSQL: Can DBeaver emulate "COPY" from "stdin"?

See original GitHub issue

PostgreSQL’s COPY command allows to copy data from stdin, the standard input, to a table; and vice-versa. That way, you can do this:

COPY students FROM stdin;
1	Denholm	Gladwin	33
2	Becka	Morris	31
3	Flora	Kingston 27
\.

Which is more compact than this, and maybe more readable:

INSERT INTO students
	VALUES
		(1, 'Denholm', 'Gladwin', 33),
		(2, 'Becka', 'Morris', 31),
		(3, 'Flora', 'Kingston', 27);

This works well when you run the query from the command line, using the psql command. But obviously, DBeaver fails to do so because it tries to parse the data as separate statements.

I know that you can put the data into an external file (i.e. a CSV file) and load it using COPY. But, if the server is in another machine, the file will be unreachable; because the command is run on the server-side, not in the client-side.

But, even if the server is run locally, the path to the data file won’t be portable. Because the path is relative to the server’s cluster directory, not the script location. In other words: you need an absolute path.

I also know that I can use the feature of DBeaver to import data. But I’m using COPY because I’m preparing and testing SQL scripts that will be run in other machines, by other users, in a semi-automated way.

This is not a vital feature, of course. I can rely on INSERT for this task. But I would like to know whether DBeaver can emulate the stdin or not.

Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kseniiaguzeevacommented, Jul 31, 2020

This function will be added in future releases

2reactions
serge-ridercommented, Nov 11, 2021

The first beta version is ready. DBeaver creates a PG-specific CSV file and loads it using COPY INTO STDIN. This feature works only for PostgreSQL, Greenplum, EDB, and Cockroach.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I use COPY in postgresql if it said that I do not have ...
I'm using DBeaver for my little projet. I'm actually stuck because the "COPY" command can't work because I don't have superuser permission.
Read more >
Data Viewing and Editing - DBeaver Documentation
Use inline editing or open the cell values in a separate editor to populate them with data (see the sections above). You can...
Read more >
COPY FROM | CockroachDB Docs
In the SQL shell, run the following command to start copying data to the users table: COPY users FROM STDIN;.
Read more >
How To Create Local Connection In Database | Install DBeaver
Hello,In this video I am sharing how to create local connection for postgresql. Also i am sharing how to install dbeaver. You can...
Read more >
Installing PostgreSQL and Dbeaver - Pratiwi Eka Puspita
We will work on database through Dbeaver that connected to Postgres. To open it up, here are the steps. ... Open the SQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found