setting up vscode to edit, format, and execute SQL++ (n1ql) queries #824
randytpierce
started this conversation in
Scorecard - development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Making vscode handle SQL++ (N1QL)
This is a sort of guide or tutorial to explain how to setup vscode to edit, format, and execute (with a keyboard binding) n1ql queries.
This should accomplish these three things...
Instructions
Install the SQLTools extension - https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools
Associate .n1ql files with SQLTools
To do this
Install the couchbase server
This will give you access to the cbq utility but you will have to put the couchbase bin directory into your PATH (like in your ~/bash_profile file or something). Mine is in /Applications/Couchbase Server.app/Contents/Resources/couchbase-core/bin.
Create a task to execute a .n1ql file from inside the editor. This goes in a tasks.json file under the .vscode directory along with the extensions.json and the settings.json and the launch.json etc. The tasks.json file should have this content...
Of course if you already have a tasks.json just put this part into the existing task list...
By clicking on this You get an editor window where you can see user keyboard bindings if any exist, or create a new one if they don't. Paste this into the editor ...
Now you have a keybinding [ctrl s] associated with the cbq-adb-cb1 task. Whenever you are editing a file with '.n1ql' as an extension it will use cbq to execute the n1ql and put the results into the terminal.
Beta Was this translation helpful? Give feedback.
All reactions