kndndrj / nvim-dbee

Interactive database client for neovim
GNU General Public License v3.0
710 stars 48 forks source link

Feature/connection loaders #9

Closed kndndrj closed 1 year ago

kndndrj commented 1 year ago

addresses #2.

Added more functionality to configure connections, save them to file, load from different sources.

Added secret injecting from environment.

cseickel commented 1 year ago

This looks pretty awesome, I'll give it a try tonight and let you know how it works. Thanks!

cseickel commented 1 year ago

I was able to add a connection interactively, but I can't figure out how to open that connection or run a query. What do I do next?

kndndrj commented 1 year ago

Hey, once you added the connection, it should appear in the drawer - except if there were any errors.

You should then be able to activate it (using da in the drawer) and every query that is executed (either from a scratchpad or using the require"dbee".execute()) will be ran on that connection.

there are still some issues with require"dbee".execute() and the error logging isn't the best - I already have a plan to address that in a future PR

cseickel commented 1 year ago

da doesn't do anything. Also, there is a > ? help line in the drawer but I can't get that to do anything either. I tried hitting <enter>, <space>, and da on both my connection and the help but nothing happens.

image

kndndrj commented 1 year ago

@cseickel press "o" to toggle the node in tree. please reffer to the config.lua for other key bindings.

I'll add this to the readme aswell

cseickel commented 1 year ago

I finally got the connections to work. My suggestion on this feature is that you really need to add in the ability to view/edit connections. I ended up finding the persistence file in order to edit the connection. The good news is that using an env variable for the password worked as expected.

Also, I'm not clear on what happens when you specify connections in the config and interactively, it seems like my config connections were being ignored.

I did see the information_schema and pg_catalog when expanding the connection, but I still haven't been able to run a query. I tried using the main window to write a query and then used BB which I found in the config file as a command to execute but it didn't do anything.

I think you really need to focus on writing a manual to explain how this is supposed to work.

kndndrj commented 1 year ago

hey, can you read the new "getting started" section in the readme and tell me if anything is still missing.

The view/edit functionality is sure interesting and I'll see what I can do.

The connections you specify in different formats are all mashed together once calling setup. The specifying connections section in readme is (I hope) pretty clear about different sources - the "add" and "remove" function are called when you add/remove connection interactively and they let you control what happens (or doesn't happen) with the connection - if you make them empty functions then nothing is written to persistence file.

I'll add the edit functionality and let you know. Thanks again for the feedback!

cseickel commented 1 year ago

This is a huge help. You might actually consider defaulting the help menu to being expanded to help first timers, then have a config option to default it to closed for people that don't need it anymore.

Also, I finally got it to work!

That edit functionality is huge though because it was really annoying to keep writing out all the details over and over because I made mistakes or accidentally closed the popup.

cseickel commented 1 year ago

You know, for me, I would prefer to just edit the entire lua or json file directly as opposed to typing it in one connection at a time. In a way you are creating a custom syntax anyhow the way you have implemented it, it might as well be a well known one that LSP/treesitter can help with.

kndndrj commented 1 year ago

Hey, very nice suggestions, thanks. I am in the process of moving a lot of things around because I have seen that some stuff is pretty confusing (like the loaders I added).

At the end of the day, yeah it would probably make sense to add an "edit conns" in the tree and it just opens a json file or something.

Anyways I'll get back to you once I refactor this a bit!

kndndrj commented 1 year ago

@cseickel Hey, I know it's been a while, but I finally came around to implementing some stuff for this. I updated the README.md with instructions. There are some breaking changes in this PR now - refer to lua/dbee/config.lua for more info.

Essentially, you pass "sources" to setup and they provide the connections to dbee. this allows more modularity like encrypted file in the future.

please take a look at it and see if you like it and if you would replace anything :)

cseickel commented 1 year ago

This is great! I say ship it!