Open derekbunch opened 1 week ago
As for the first error, It looks like it's about being unable to read the connections properly, specifically in terms of choosing the right DBMS based on the url string.
connections.json
should be located in the sqlua folder, which is in the standard nvim data folder (usually ~/.local/share/nvim/sqlua/connections.json
)
and should be a json array like this:
[
{
"url": "mysql://admin:password@localhost/mydb",
"name": "mydb-con"
},
{
"url": "postgres://user@127.0.0.1:5432/public",
"name": "psql-db"
}
]
Url should be something like:
dbms://user:pass@host:port/dbname
With dbms
being one of snowflake
, mariadb
, mysql
, or postgres
Can you post an example of your connections.json
with sensitive info removed?
[
{
"url": "postgres://postgres:x@0.0.0.0:5432/xxxx?sslmode=disable",
"name": "xxxx local"
},
{
"url": "snowflake",
"name": "snowflake"
}
]
ive tried the same postgres connection string with vimdadbod and tableplus and it worked in each of them
I'm having a hard time reproducting the same error, although I did produce another.
It looks like having a space in the connection name throws some errors all around when trying to interact, as it uses that name to make the dir, check fs, and other things. Try renaming it without whitespace to see if that helps. I'm gonna start working on a PR for that to allow spaces.
As for the initial issue, I'm not entirely sure why it's happening. Are you on Windows or MacOS by any chance? The only thing the code does by that point is reading the connections.json
file, doing a find on ://
, grabbing the dbms name from before that match, and returning an object based on the name of the dbms matched.
I am on MacOS.
and i did try replacing the space with an underscore and do still see the same error. I will try to take a look at the code and see if i can narrow down where the issue is occurring or what might be happening.
so i went into the code and the line that is initially giving me issues is
ui.lua #1447
vim.api.nvim_buf_delete(1, {})
i commented this line and i am able to get the UI to load.
however, when i try to open a connection to the database, i get this error:
Error executing vim.schedule lua callback: ...ch/.local/share/nvim/lazy/sqlua.nvim/lua/sqlua/files.lua:71: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
...ch/.local/share/nvim/lazy/sqlua.nvim/lua/sqlua/files.lua:71: in function 'setup'
...bunch/.local/share/nvim/lazy/sqlua.nvim/lua/sqlua/ui.lua:747: in function 'addConnection'
...share/nvim/lazy/sqlua.nvim/lua/sqlua/connectors/base.lua:395: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
ive done some debugging and it looks like this error comes from the fact that my .../.local/share/nvim/sqlua/db_name
folder is empty.
Is the expectation that i should have some config here? or that the plugin writes some files automatically here?
hmm, i just tried adding an empty file to my .../.local/share/nvim/sqlua/db_name
folder and things seem to be working now.
touch .../.local/share/nvim/sqlua/db_name/some_file
not really sure what the purpose of the buf_delete is or why files must be created in the db_name directory, but with those 2 changes, i am able to run queries against my database
Same problem: /.local/share/nvim/lazy/sqlua.nvim/lua/sqlua/ui.lua:1478: Invalid buffer id: 1
when starting with
nvim '+SQLua'
i get the following error messagewhen trying to start it using
:SQLua
in an already open session, i get the following error messageI've tried starting with:
nvsql
:SQLua
:SQLua <connection_name>
nvsql <connection_name>
Not entirely sure what to try to get it to work.
I have defined some connections in the
connections.json
to see if maybe that was the issue but same error messages are the result.sqlua.lua
Neovim --version
LazyVim version
SQLua version
If there is any other information i can provide, please let me know!