Questions tagged [psql]

25 questions
6
votes
3 answers

To have Vim Psql's editor

I have a Fresh Ubuntu installation. I have no personal dot-files active. I run unsuccessfully \e file.sql in Psql, when I have the following in my .bashrc, since Nano opens instead of Vim export VISUAL=/usr/bin/vim export EDITOR=/usr/bin/vim export…
4
votes
0 answers

Can't tab complete in psql

For some reason, tab-completion isn't working in psql on my Mac. I can tab complete table and field names just fine in Ubuntu, but pressing TAB fails to work in Mac OS X. I can successfully use my Up/Down arrow keys to navigate back and forth in…
mcandre
  • 3,098
3
votes
1 answer

pgAdmin III writes files with junk in them, which causes PSQL to fail

I encountered the dilemma of needing to run some psql console commands because a colleague needed to use psql's \i directive in a saved script to execute additional SQL-statements from another file, but I noticed that psql was choking on these files…
3
votes
2 answers

Viewing wide terminal output in tmux

I enjoy using psql with Tmux and Vim, using Vim to edit my queries and send them to psql in another Tmux pane. This is a fantastic workflow, far superior to a GUI like DBeaver in my opinion, but: It doesn't take many columns for psql to be unable to…
LondonRob
  • 455
2
votes
1 answer

How to display server name in psql prompt

I have two servers running same PostgreSQL databases where one is production and one is development snapshot. It would be very handy for me if I could show the server name in the psql prompt (like this): database_name@server_name > Is there any…
2
votes
1 answer

(-bash: initdb: command not found) When installing postgres mac

I get the following error (-bash: initdb: command not found) in the terminal when trying to install postgres on my mountain lion mac osx? Also, does any one have a good resource for installing postgres, and setting it up? Working with bash and…
user630581
2
votes
0 answers

How to manually uninstall PGAdmin4 from macOS?

I have tried removing manually by removing PGAdmin4 from my applications folder. I also followed a few steps from this post here. To my surprise some of the files existed and I was able to remove them. However now when I run: ps aux | grep…
Ahmed
  • 121
2
votes
1 answer

-bash: psql: command not found

I'm on a Mac 10.11 running psql -h localhost -U monitor -W postgres and I kept getting -bash: psql: command not found This is what I have in my paths. /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/pgsql/bin
code-8
  • 444
1
vote
1 answer

psql ignores my PAGER variable

I want to use less as my default pager. Therefore I have PAGER=less in my .bashrc. It's sourced properly: $ echo $PAGER less However, psql still uses more if I call it with psql. BUT: If I call it with PAGER=less psql, psql does use less. I have no…
musiKk
  • 375
1
vote
1 answer

Postgresql query within a bash script

We are having an issue with a postgresql bash query. The output of the query from the bash script add's additional quotes around the date. Please can you help me fix it?! Script: #!/bin/sh lastmonth=$(date -d "-1 month -$(($(date +%d)-1)) days"…
1
vote
0 answers

PostgreSQL sum function resurns different result when run multiple of times with psql

I have this query : SELECT SUM(median) FROM my_table WHERE id = 100 -- median is of type float4 When I run from psql, it returns slightly different result for multiple of runs (For example 1000.08, 1001.02, ...) The number of entries contributing…
Philippe
  • 220
1
vote
1 answer

psql command not taking password from .pgpass file

psql -U postgres -h 127.0.0.1 postgres I am using the above command to connect to the postgres running on my system. It asks for password Whereas I have setup .pgpass file in the current directory with content -…
bittu
  • 11
1
vote
1 answer

bash - passing an sql query as an argument to psql

I have the following SQL query that executes correctly in the psql shell: SELECT c.component_name AS "Component", c.component_version_name AS "Component Version", c.version_origin_id AS "Version Origin ID" FROM reporting.component c…
xgkphdx
  • 11
1
vote
1 answer

Is there an equivalent of .ssh/config for use with psql?

In the .ssh/config file (at least that's the usual default location), I can define hostname, username, port, etc. for ssh connections and store it with an easy to use name. That allows me to call ssh or scp without having to do all the tedious…
karpfen
  • 161
1
vote
1 answer

Why do I get error "/var/lib/pgsql/.role.sh: not found" from postgres in docker?

I have PostgreSQL running in Docker. The host system is Ubuntu 18.04.3. Every time I execute some SQL in PostgreSQL I get /var/lib/pgsql/.role.sh: not found Does anyone know why this is or at least what the .role.sh script is? The SQL code seem to…
1
2