usql icon indicating copy to clipboard operation
usql copied to clipboard

How to .usqlpass

Open MichalisDBA opened this issue 1 year ago • 5 comments

Hello.

I think i am missing something.

We have 2 Microsft SQL servers. MS1 and MS2

I create a .usqlpass file and put the following config

mssql:*:*:*:myusername:password1 mssql:*:*:*:myusername:password2

How to specify in the connection string usql mssql:// that when i want to connect to MS2 server i want the credentials of the line with password2?

The username is the same on both servers. Only the password changes.

MichalisDBA avatar Apr 19 '24 12:04 MichalisDBA

One of the entries in .usqlpass needs to have a hostname.

nineinchnick avatar Apr 19 '24 12:04 nineinchnick

Those two wildcard entries read in English like this:

Connect to any MSSQL server as myusername with the password as password1 AND password2

Which doesn't really make sense.

nineinchnick avatar Apr 19 '24 12:04 nineinchnick

Thanks for the info but.

I put this in .usqlpass

mssql:*:*:*:myusername:password1
mssql:10.1.0.10:*:*:myusername:password2

and then tried to connect like this

usql mssql://10.1.0.10/DB_NAME

and says login failed and asked for password.

MichalisDBA avatar Apr 19 '24 12:04 MichalisDBA

You need to have the more specific entry first, so switch them. They're matched from top to bottom.

nineinchnick avatar Apr 19 '24 12:04 nineinchnick

Yes that works. Maybe it has to be better documented. Thank you!

MichalisDBA avatar Apr 19 '24 13:04 MichalisDBA

Please see the updated README.md, and use \cset and/or the config.yaml for usql. Thanks.

kenshaw avatar May 11 '24 00:05 kenshaw