Add SQL Layer and LSP supportλ︎
Space f e d to open the Spacemacs configuration. Add the
sql layer to the
lsp layer is used then LSP is set as the backend for all layers and will connect to an SQL LSP server when opening a related SQL buffer.
Or manually set LSP as the backend using a layer variable (if
lsp has not been added to the Spacemacs configuration)
Install SQL LSP Serverλ︎
sqls provides the LSP server implementation for the SQL layer.
Install the latest sqls release for the Operating System in use.
Linux install: download the Linux release, extract the archive and move the
sqlsbinary file to
sqls -help or
sqls -version in a terminal confirms the binary is working.
Adding database connections via LSPλ︎
sql-lsp-sqls-workspace-config-path as an SQL layer variable defines the location of database connections in JSON format
workspace: Emacs workspace directory, XDG location
root: top level of current project
Database configuration for SQL LSPλ︎
Example database connection in JSON.
sql-lsp-sqls-workspace-config-path set as
workspace the configuration should be saved to the Emacs workspace directory, e.g.
Avoid saving plain-text passwords in projects
Saving plain-text passwords in configuration files is a security risk. Passwords should definitely not be checked into a code sharing service (GitLab, GitHub, etc).
workspace option minimises the risk of adding passwords to a shared code service as it is not part of any source code projects, although it still presents some risk if security of the Operating System is breached.
Add database connections securely via Elisp
Connections can be defined in Elisp and added to the
dotspacemacs/user-config section of the Spamcemacs configuration file, optionally using a PGP encrypted password for greater security.