doctl icon indicating copy to clipboard operation
doctl copied to clipboard

Database Connection Flags

Open dbpolito opened this issue 4 years ago • 1 comments

At DigitalOcean Database panel, you can get the mysql -u... command snipped, which is called Flags on the Connection Details section.

With doctl i wasn't able to find a way to print that for me, i know i can use --output=json | jq and build myself but would be very useful to have this ready for me, even better if we do not include -D defaultdb part.

doctl db connection [dbid] --format=Flags

dbpolito avatar Apr 28 '20 01:04 dbpolito

Thanks for the feedback. I know this isn't exactly what you are looking for, but I did want to point out that the API does return the connection URI that is also displayed in the control panel. This can be used to connect to the database without parsing JSON:

psql $(doctl databases connection DATABASE_ID --format URI --no-header)
redli -u $(doctl databases connection DATABASE_ID --format URI --no-header)
mysqlsh --uri $(doctl databases connection DATABASE_ID --format URI --no-header)

Unfortunately mysql does not support using that format, but you can use MySQL Shell as shown above.

See: https://dev.mysql.com/doc/mysql-shell/8.0/en/

andrewsomething avatar Apr 28 '20 15:04 andrewsomething