Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary parameters to tsh db connect #52352

Open
milos-teleport opened this issue Feb 20, 2025 · 2 comments
Open

Allow arbitrary parameters to tsh db connect #52352

milos-teleport opened this issue Feb 20, 2025 · 2 comments
Labels
c-edm Internal Customer Reference database-access Database access related issues and PRs feature-request Used for new features in Teleport, improvements to current should be #enhancements

Comments

@milos-teleport
Copy link
Contributor

Current situation

Currently, we provide the users with an option to run tsh db connect which, in the background, creates a tunnel and starts up a database client

What would you like Teleport to do?

Allow for users to pass arbitrary parameters to the database client - either via the tsh db connect or by using a separate tsh db ... command.

What problem does this solve?

Allows greater flexibility to users

If a workaround exists, please include it.

tsh db proxy followed by database client one-liners

@milos-teleport milos-teleport added the feature-request Used for new features in Teleport, improvements to current should be #enhancements label Feb 20, 2025
@milos-teleport milos-teleport changed the title Allow for inline execution of database queries using tsh db Allow arbitrary parameters to tsh db connect Feb 20, 2025
@milos-teleport milos-teleport added database-access Database access related issues and PRs c-edm Internal Customer Reference labels Feb 20, 2025
@4durban
Copy link

4durban commented Feb 20, 2025

We were looking for something that allow us to execute a query without the need for the prompt, we would like something like:

tsh ssh
...
Args:
  <[user@]host>  Remote hostname and the login to use
  [<command>]    Command to execute on a remote host

where you can provide the command as parameter and it gets executed in the remote host.

Taking this into account and since in tsh ssh you have this parameter

-o, --option OpenSSH options in the format used in the configuration file

I do not see any problem with doing the same for tsh db, you are already launching a db client under the hood, so, why not give the user the possibility of providing a query (which indeed is just another parameter, -e in mysql client) so there is no need for interactive action?

something like

tsh db
...
Args:
  <db>  Remote database
  [<query>]    Query to execute on a remote database

I think that it would useful. I am just focusing in -e parameter because it is what I need but I guess that we should be able to provide any parameter that the database client accepts.

@milos-teleport
Copy link
Contributor Author

Hi @4durban - I asked for the open-ended parameters to be passed because implementing what you are asking would require logic based on the database type used. This adds complexity but not much value to the user. I feel it's much more valuable if the user can provide the arbitrary parameters to the database client themselves

For example (Postgres):

tsh db connect <teleport-params> --db-params '-c "select * from dummy_table;"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-edm Internal Customer Reference database-access Database access related issues and PRs feature-request Used for new features in Teleport, improvements to current should be #enhancements
Projects
None yet
Development

No branches or pull requests

2 participants