I have the following configuration in emacs init files to set a variable (user
) to the current Unix login user:
(setq sql-postgres-login-params
`((user :default ,user-login-name)
(database :default ,user-login-name)
(server :default "127.0.0.1")
(port :default 5432)))
With this, I was able to login into PostgreSQL databases with the Unix login user as the default database user. However, this stops working when the Unix user name contains dashes -
, and needs to be double-quoted. For example, in PostgreSQL, when the unix user is myuser
, it's OK to use it directly as the database user name. However, when the user name is my-user
, it needs to be quoted as "my-user"
to be used as a user name (or database name). My question is:
How can I make the user-login-name
in the above example quoted?
e.g. if ,user-login-name
is my-user
, how do I use "my-user"
instead?
I am not familiar with elisp, and the below is the best I can come up with (concatenating with "\""
s). But database login still fails.
(setq sql-postgres-login-params
`((user :default ,(concat "\"" user-login-name "\"") )
(database :default ,(concat "\"" user-login-name "\"") )
(server :default "127.0.0.1")
(port :default 5432)))