Score:0

Can't find psqlrc file for Postgresql on Windows

ng flag

Kind of new to IT and trying to learn Postgresql. I was having a problem where my SQL commands weren't outputting to the psql prompt. This was fixed with \pset pager off

That's great! Problem is I have to type it in every time I open the prompt. So I heard about a psqlrc.conf file where I can set variables. Problem is I can't find it.

I tried following this guide - https://mladenuzelac.blogspot.com/2016/01/psqlrc-in-windows.html, but no Postgresql folder exists under C:\Users\User\AppData\Roaming\postgresql.

I've added both the bin and lib to the path successfully as well, for both the system and user. Not sure what I'm doing wrong at this point :).

Any help would be greatly appreciated!

Thanks in advance!

Score:0
us flag

Simply create one in %appdata%\postgresql.
Rule of thumb is if you know a process uses a configuration file, and you can not find that file, you can just make one yourself.

There is also an important distinction between Linux and Windows psqlrc files that needs to be noted:

  • On Linux psql uses ~/.psqlrc file;
  • On Windows - %appdata%\postgresql\psqlrc.conf.

(note the difference of . and .conf).

jarjarbinks99 avatar
ng flag
I'll give this a try Pawel and let you know how it goes!
jarjarbinks99 avatar
ng flag
So I did that, created the postgresql directory in appdata then the conf file but still no luck. Is there another step I'm missing for the file to take effect?
p10l avatar
us flag
Weird, it should work out-of-the-box. You can try the following: 1. restart terminal instance; 2. Check if `PSQLRC` env variable is set with `Get-Item -Path Env:PSQLRC` in PowerShell; If it's not, set it with `$Env:PSQLRC = "C:\Users\<your-username>\AppData\Roaming\postgresql\psqlrc.conf"`.
jarjarbinks99 avatar
ng flag
Ya no luck my friend. Maybe windows isnt the best environment for this. When I start building it on centos I'll start looking at it more seriously. Even loaded up a fresh windows 10 VM with nothing on it and still doesn't work.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.