Skip to main content
the problem is not setting sql-password, but that sql-postgres ignores it
Link

How can I programatically set Set the value of 'sqlpassword for sql-password'postgres

Source Link

How can I programatically set the value of 'sql-password'

I have a question regarding connecting to a sql database programmatically. Ideally I would like to have a function with similar functionality to the sql-postgres but instead of interactively prompting me for each part of the connection string, I would just like to programmatically provide all of the arguments.

I seemed to make some progress by setting the defaults the database uses as follows:

    (setq sql-user url-user)
    (setq sql-server "localhost") 
    (setq sql-database "myDatabase")
    (setq sql-port db-port)
    (setq sql-password my-password)
    (call-interactively #'sql-postgres)

This gets me 90% the way there. The only thing missing is the prompt still asks me for my password and wont take the default I set. I was looking around for a workaround but I could't seem to figure it out. If there is a better way to go about this problem I would be glad to hear ideas.