Skip to content

SQL (sqls)#


For more information about the LSP server, check sqls.


go install

Debugger: Not available#

root_file: docs/manual-language-docs/

Sample configuration:#

(add-hook 'sql-mode-hook 'lsp)
(setq lsp-sqls-workspace-config-path nil)
(setq lsp-sqls-connections
    '(((driver . "mysql") (dataSourceName . "yyoncho:local@tcp(localhost:3306)/foo"))
      ((driver . "mssql") (dataSourceName . "Server=localhost;Database=sammy;User Id=yyoncho;Password=hunter2;"))
      ((driver . "postgresql") (dataSourceName . "host= port=5432 user=yyoncho password=local dbname=sammy sslmode=disable"))))

Alternatively, you can leave lsp-sqls-workspace-config-path to the default "workspace" value, and put a json file in <project>/.sqls/config.json containing

  "sqls": {
    "connections": [
        "driver": "mysql",
        "dataSourceName": "yyoncho:local@tcp(localhost:3306)/foo"

Now lsp should start in sql-mode buffers, and you can pick a server connection with M-x lsp-execute-code-action and "Switch Connections" (or directly with M-x lsp-sql-switch-connection). You can change database with M-x lsp-execute-code-action and "Switch Database" (or M-x lsp-sql-switch-database).

Available configurations#


Type: (repeat (alist :key-type (choice (const :tag Driver driver) (const :tag Connection String dataSourceName)) :value-type string))

Default: nil

The connections to the SQL server(s).


Type: file

Default: sqls

Path to the sqls binary.


Type: number

Default: 0.5

Timeout to use for sqls requests.


Type: (choice (const workspace) (const root))

Default: workspace

If non-nil then setup workspace configuration with json file path.

Last update: June 10, 2024