I connected to remote PostgreSQL database using IntelliJ IDEA 2017.2.1 successfully and executed some select queries on one of the tables. I got the results. I wanted to dump the results data to a file or the clipboard, but the 'Dump Data' command is disabled. Any idea why that might be or how to tell the reason? Thanks.
It does not matter which output format I choose from the Select on the left of the Dump Data button. I have updated the DB driver to the latest version.
I am using:
IntelliJ IDEA 2017.2.1
Build #IU-172.3544.35, built on July 31, 2017
Mac OS X 10.12.6
The Dump Data To File/Clipboard action becomes disabled for those query results (and corresponding SQL Console) for which database parameters (like current database/schema or search path for Postgres/Redshift) have been changed after you got those query results.
I.e. when you execute select query using one current schema (search path in Postgres/Redshift) and then change the schema (i.e. with the 'use' statement) to another schema(search path in Postgres/Redshift).
And it should get enabled after you re-run the query with the changed parameters or revert them back.
Repeating query as suggested did not help. Nor did a regular restart. Invalidate Caches and Restart did the trick.
Related
I have a Django project connecting to a PostgreSQL database which I develop in PyCharm, and I want to enable PostgreSQL history logging.
There is PSQL_HISTORY env variable set to /home/user/apps/postgres/logs/.pycharm_log, but when I start the project in PyCharm and update some data via the Django Admin (which certainly hits the database) -- nothing gets logged and the file is not created at all.
Is there a way to make PyCharm and PSQL_HISTORY work together as I expected?
'psql' is the name of a specific client tool. Why would a completely different tool use psql's configuration options? If you want to log every statement sent to the server, you could configure that in the server side with log_statement=all.
Running any sort of query on pgAdmin 4 just returns a 'table_oid' under messages.
I am able to get the necessary data when running the query from the command line, for example
SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6 29.5, 75.15 29.53)'));
I understand that table_oid refers to the object id of the table, but I have no idea how to access it.
Pardon me please if it is a simple question, but I am unable to find any resources online
Expected:
010300000001000000040000009A99999999C9524048E17A14AE873D4000000000004053400000000000003D4066666666666653400000000000803D409A99999999C9524048E17A14AE873D40
Actual:
table_oid
From pgAdmin 4 project tracker:
Temporary solution until next release and tested in my ubuntu 18.04 machine:
Replace these two 2 files:
/usr/share/pgadmin4/web/pgadmin/tools/sqleditor/__init_*_py
/usr/share/pgadmin4/web/pgadmin/tools/sqleditor/command.py
Link to files:
__init_*_.py
command.py
Note:
The first file's name is __init_*_py, without the *.
Try Squirrel SQL - Universal SQL Client. It's an extremely useful SQL client. I use it to access SQL Server, PostgreSQL, MySQL, Access. It's not as good looking as pgAdmin4.
Install JAVA first, if not already installed.
Install Squirrel SQL.
Download the latest PostgreSQL JDBC driver, e.g. postgresql-42.2.6.jar, and put it into a convenient location.
Open/Start Squirrel.
Click the Drivers Tab and scroll down to PostgreSQL. Double click PostgreSQL. A "Change Driver: PostgreSQL" dialog box/window will open.
Click the Extra Class Path tab and click the Add button. Navigate to and choose the PostgreSQL JDBC Driver that was downloaded in step 3. above.
Click the List Drivers button, "org.postgresql.Driver" should appear in the Class Name drop down box.
Click OK.
Setup PostgreSQL JDBC Driver
The driver should now be setup.
Click the Aliases tab to setup a connection to your database. See my example screenshots.
Setup Database Connection
I am using intellij with postgres, and highlight sql commands to run them.
I also have postgres running in my terminal, and I am getting different results from the same query when run in intellij vs. when run in the terminal.
Here is the command run from Intellij:
The result shows one entry present:
However, running the same command in the terminal shows no table entries present.
Intellij and the terminal are connecting to the same database and port as shown by Intellij's connection settings
and by the result of \conninfo run in the terminal.
Furthermore, the schema matches as shown by Intellij's connection settings (shown above) and by the result of the terminal's \d+ visitor_sign_in command
Why does this same command give different results when run in Intellij vs. when run in the terminal?
Based on your most recent comment ("yes running select * from pg_stat_activity; does show 'idle in transaction'."), here is what I believe is happening.
You have two connections, A and B.
A starts a transaction, inserts data, and then selects from that table. The table shows data (the data that was just inserted).
B connects, and selects from the same table. Since A has not committed, B does not see that data. In order for the data inserted by A to be visible to any other connections, you need A to commit its transaction.
Now, I don't know why IntelliJ is not offering you the opportunity to commit your transaction, but that lack of commit is the cause of your visibility problem.
I am using execute command tag from my liquibase changesets and this inturn is configured to run the sqls in oracle instant client sql plus.
when i run a liquibase update on my changelogxml everything works fine and the liquibase update is sucessfull.I can see the changes to the table also.
But when i try to fail the update process by giving a syntax error in my sql file refered in the changeset.Liquibase still returns liquibase update sucessfull.I expected it to throw sql errors.The sql when run seperately in toad throws syntax error.What should i do to get the error displayed out.?
Datical has created a custom Liquibase change tag that executes SQL using the sqlplus command line client. It was surprisingly much more complicated that you might think.
Some of the issues we had to deal with:
we had to do things to ensure that the sql files always had certain statements in place, and never had certain other statements. This might include things like setting the schema, ensuring that the only spool commands were ones we knew about, that the script had an 'EXIT' command, and ensuring that whenever there was a SQL error that the exit code was returned.
The sqlplus executable does not return an exit code (i.e. a non-zero exit code form the native process) in all cases, and instead will write errors to an error table in the database. The table where sqlplus writes errors is called sperrorlog, and this may be what you will need to look into.
I can't really go into all the details, but just know that what you are attempting to do is neither simple nor straightforward.
Q: How can I diagnose and correct problems with the Query tool connection.
Using pgAdmin4 1.0-rc1 to connect to a local host "PostgreSQL 9.5.3, compiled by Visual C++ build 18..."
I can connect and drill down to my schema. I use the context menu to select 'Query tool'. The editor shows the correct database#host:port in the editor header bar.
When I execute a simple query, or any query
select 1 as first;
I get the message
"Not conencted to the server or the connection to the server has been closed.
instead of the expected results.
The editor alwa
This issue has been resolved now,
Upgrade pgAdmin4 to version 1.3. https://www.pgadmin.org/download/
All you have to do is wrap the schema, table, column names with double quotation marks in every sentence.