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

Is it possible to open a connection as READONLY? #273

Open
brunobmello25 opened this issue Sep 9, 2024 · 6 comments
Open

Is it possible to open a connection as READONLY? #273

brunobmello25 opened this issue Sep 9, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@brunobmello25
Copy link

Similar to a connection option we have in datagrip. This is really handy when connecting to production databases for debug purposes: where we definitely want to avoid running a write query by mistake.

@kristijanhusak kristijanhusak added the enhancement New feature or request label Sep 9, 2024
@kristijanhusak
Copy link
Owner

Which DB? I wanted to add something like that, but it's a bit tricky to hook into the connection to add it, at least for postgres.

@brunobmello25
Copy link
Author

Which DB? I wanted to add something like that, but it's a bit tricky to hook into the connection to add it, at least for postgres.

It's postgres. Yeah, I was trying to figure out how to make it readonly within the connection url but couldn't really find an answer myself either =/ Maybe I could try to figure out how datagrip does so we can have some sort of reference

@titaniumtraveler
Copy link

AFAIK that should be possible, by configuring vim-dadbod to use the right postgresql-role.
(See https://www.postgresql.org/docs/17/role-membership.html)
I'm not sure which role attributes you would have to give it though.

@jay-babu
Copy link

+1 would also like this. @kristijanhusak, https://stackoverflow.com/questions/41960217/connecting-to-postgres-database-with-read-only-access. is it possible to run this after connecting? I would explicitly run something to make it read write obviously. I see table helpers, https://github.com/kristijanhusak/vim-dadbod-ui#table-helpers, however I don't think that would work. Maybe if there was auto command like post connect, i could run the set session read only

@kristijanhusak
Copy link
Owner

@jay-babu each query is run as a separate call, there is no persistent connection.
I'm thinking of modifying the query before it's executed to achieve this, but I still need to do some thorough testing on it.

@jay-babu
Copy link

@jay-babu each query is run as a separate call, there is no persistent connection.

I'm thinking of modifying the query before it's executed to achieve this, but I still need to do some thorough testing on it.

Oh hmmm. It doesn't grab and hold a connection/session, I see. If there was a way to run pre and post scripts that'd work too. Maybe just like auto commands in nvim

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

No branches or pull requests

4 participants