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

Add support for running a command to get the database connection string in postgrestools.jsonc #302

Open
psteinroe opened this issue Apr 4, 2025 · 1 comment
Assignees

Comments

@psteinroe
Copy link
Collaborator

Discussed in #292

Originally posted by remorses April 1, 2025
I want to use the Supabase database directly instead of a local database, to do that you could add support for a config option dbCommand to get the database uri via stdout

{
  "$schema": "./docs/schemas/latest/schema.json",
  // get the database uri using dotenv-cli npm package
  "dbCommand": "dotenv -- bash -c 'echo $DATABASE_URL'",
  // get database uri using doppler
  "dbCommand": "doppler secrets get --plain DATABASE_URL",
}

This allows to get the database url using tools like Doppler or dotenv

@juleswritescode juleswritescode self-assigned this Apr 4, 2025
@willruggiano
Copy link

willruggiano commented Apr 4, 2025

I would also love the ability to use InitializeParams and/or the workspace/didChangeConfiguration notification to configure this stuff, rather than be limited to a configuration file. The latter could enable switching database connections. Both options would then allow the client to determine the db parameters however they wanted, e.g. something along the lines of (in Neovim with lspconfig);

require("lspconfig").postgres_lsp.setup {
  settings = {
    postgres_lsp = {
      db = load_from_env()
    },
  }
}
-- You could map this in on_attach, for example. Or use Telescope. Or whatever.
function switch_database_connection(client --[[@type vim.lsp.Client]])
  client.notify(
    "workspace/didChangeConfiguration",
    {
      settings = { ... as above ... }
    }
  )
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants