Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SQL language server written in Go.

License

NotificationsYou must be signed in to change notification settings

sqls-server/sqls

Repository files navigation

test

An implementation of the Language Server Protocol for SQL.

Note

This project is currently under development and there is no stable release. Therefore, destructive interface changes and configuration changes are expected.

Features

sqls aims to provide advanced intelligence for you to edit sql in your own editor.

Support RDBMS

Language Server Features

Auto Completion

completion

  • DML(Data Manipulation Language)
    • SELECT
      • Sub Query
    • INSERT
    • UPDATE
    • DELETE
  • DDL(Data Definition Language)
    • CREATE TABLE
    • ALTER TABLE

Join completion

If the tables are connected with a foreign key sqls can completeJOIN statements

join_completion

CodeAction

code_actions

  • Execute SQL
  • Explain SQL
  • Switch Connection(Selected Database Connection)
  • Switch Database

Hover

hover

Signature Help

signature_help

Document Formatting

document_format

Installation

go install github.com/sqls-server/sqls@latest

Editor Plugins

DB Configuration

The connection to the RDBMS is essential to take advantage of the functionality provided bysqls.You need to set the connection to the RDBMS.

Configuration Methods

There are the following methods for RDBMS connection settings, and they are prioritized in order from the top.Whichever method you choose, the settings you make will remain the same.

  1. Configuration file specified by the-config flag
  2. workspace/configuration set to LSP client
  3. Configuration file located in the following location
    • $XDG_CONFIG_HOME/sqls/config.yml ("$HOME/.config" is used instead of$XDG_CONFIG_HOME if it's not set)

Configuration file sample

# Set to true to use lowercase keywords instead of uppercase.lowercaseKeywords:falseconnections:  -alias:dsn_mysqldriver:mysqldataSourceName:root:root@tcp(127.0.0.1:13306)/world  -alias:individual_mysqldriver:mysqlproto:tcpuser:rootpasswd:roothost:127.0.0.1port:13306dbName:worldparams:autocommit:"true"tls:skip-verify  -alias:mysql_via_sshdriver:mysqlproto:tcpuser:adminpasswd:Q+ACgv12ABx/host:192.168.121.163port:3306dbName:worldsshConfig:host:192.168.121.168port:22user:sshuserpassPhrase:ssspassprivateKey:/home/sqls-server/.ssh/id_rsa  -alias:dsn_verticadriver:verticadataSourceName:vertica://user:pass@host:5433/dbname

Workspace configuration Sample

  • setting example with vim-lsp.
ifexecutable('sqls')augroupLspSqlsautocmd!autocmdUserlsp_setupcalllsp#register_server({\'name':'sqls',\'cmd': {server_info->['sqls']},\'whitelist': ['sql'],\'workspace_config': {\'sqls': {\'connections': [\        {\'driver':'mysql',\'dataSourceName':'root:root@tcp(127.0.0.1:13306)/world',\        },\        {\'driver':'postgresql',\'dataSourceName':'host=127.0.0.1 port=15432 user=postgres password=mysecretpassword1234 dbname=dvdrental sslmode=disable',\        },\      ],\    },\  },\})augroupENDendif
  • setting example with coc.nvim.

Incoc-settings.json opened by:CocConfig

{"languageserver": {"sql": {"command":"sqls","args": ["-config","$HOME/.config/sqls/config.yml"],"filetypes": ["sql"],"shell":true        }    }}
require'lspconfig'.sqls.setup{on_attach=function(client,bufnr)require('sqls').on_attach(client,bufnr)-- require sqls.nvimendsettings= {sqls= {connections= {        {driver='mysql',dataSourceName='root:root@tcp(127.0.0.1:13306)/world',        },        {driver='postgresql',dataSourceName='host=127.0.0.1 port=15432 user=postgres password=mysecretpassword1234 dbname=dvdrental sslmode=disable',        },      },    },  },}
  • Setting example for Sublime Text 4

    Install the LSP Client by Opening the command palette and runPackage Control: Install Package, then selectLSP.

    OpenPreferences > Package Settings > LSP > Settings and add the"sqls" client configuration to the"clients":

{    "show_diagnostics_count_in_view_status": true,    "clients": {        "sqls": {            "enabled": true,            "command": ["/path/to/sqls binary"],            "selector": "source.sql"        }    }}

I'm sorry. Please wait a little longer for other editor settings.

Configuration Parameters

The first setting inconnections is the default connection.

KeyDescription
connectionsDatabase connections

connections

dataSourceName takes precedence over the value set inproto,user,passwd,host,port,dbName,params.

KeyDescription
aliasConnection alias name. Optional.
drivermysql,postgresql,sqlite3,mssql,h2. Required.
dataSourceNameData source name.
prototcp,udp,unix.
userUser name
passwdPassword
hostHost
portPort
pathunix socket path
dbNameDatabase name
paramsOption params. Optional.
sshConfigssh config. Optional.

sshConfig

KeyDescription
hostssh host. Required.
portssh port. Required.
userssh user. Optional.
privateKeyprivate key path. Required.
passPhrasepassPhrase. Optional.

DSN (Data Source Name)

See also.

Contributors

This project exists thanks to all the people who contribute.

Inspired

I created sqls inspired by the following OSS.

About

SQL language server written in Go.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors25


[8]ページ先頭

©2009-2025 Movatter.jp