sqls-server / sqls

SQL language server written in Go.
MIT License
1.01k stars 68 forks source link

How to setup for sqlite3 #161

Open raffaem opened 5 months ago

raffaem commented 5 months ago

I'm not sure how to setup for neovim and sqlite3.

I have initialized it like:

lspconfig.sqls.setup {
    on_attach = function(client, bufnr)
    require('sqls').on_attach(client, bufnr) -- require sqls.nvim
  end,
  settings = {
    sqls = {
      connections = {
        {
          driver = 'sqlite3',
          dataSourceName = '/path/to/my/db.sqlite3',
        },
      },
    },
  },
  capabilities = capabilities }

which seems not optimal as I have to change that option everytime I change db I work on.

In any case it doesn't work.

It shows a notification "no database connection".

How to set it up properly for neovim and sqlite3?

Can we add a Discussion section to this repo?

jamietanna commented 3 months ago

I believe that you need to have a ~/.config/sqls/config.yml set, i.e.:

lowercaseKeywords: false
connections:
  - alias: DMD
    driver: sqlite3
    dataSourceName: file:/home/jamie/dmd.db

You can specify multiple connections, then use :SqlsSwitchConnection to swap between the defined databases

jgarte commented 1 month ago

This doesn't work for me and I have:

lowercaseKeywords: false
connections:
  - alias: toys
    driver: sqlite3
    dataSourceName: file:/home/jgart/.cache/guix/toys/db.sqlite

The server just dies with the following:


Saving file /home/jgart/.config/sqls/config.yml...
Wrote /home/jgart/.config/sqls/config.yml
(No changes need to be saved)
[jsonrpc] Server exited with status 1
eglot--error: [eglot] -1: Server died
Quit
Mark set
next-line: End of buffer [3 times]
next-line: End of buffer