@@ -27,3 +27,45 @@ You have 3 methods to execute queries. Run from selection, run from bookmarks, r
27271 . Select ` SQLTools History: Run ` from command palette.
28282 . Pick the query you want from the list.
29293 . Wait for the results to show up.
30+
31+ ## Queries with parameters
32+
33+ It also supports query string replacements with parameters either defined in ` variables ` or
34+ provided with ` inputBoxes ` .
35+
36+ To enable query parameters replacements, you need to provide some additional configs.
37+ In in your ` workspaceFolder ` , edit the file ` .vscode/settings.json ` . Make sure that you have
38+ the following parameters enabled:
39+
40+ ``` json
41+ "sqltools.queryParams.enableReplace" : false , // enables string replacement.
42+ // the following regex, will match named params in your variables files
43+ "sqltools.queryParams.regex" : " \\ $[\\ d]+|([@:$][\\ w]+)" ,
44+
45+ // a connection example...
46+ "sqltools.connections" : [
47+ {
48+ "previewLimit" : 50 ,
49+ "server" : " localhost" ,
50+ "port" : 5432 ,
51+ "driver" : " PostgreSQL" ,
52+ "name" : " MyDb" ,
53+ "group" : " Locals" ,
54+ "database" : " world-db" ,
55+ "username" : " world" ,
56+ "password" : " world123" ,
57+ "askForPassword" : false ,
58+ "variables" : {
59+ ":name" : " '%e%'" ,
60+ }
61+ }
62+ ]
63+ ```
64+
65+ In this case, when you execute your query, every word that matches ` :name ` will
66+ be automatically replaced for ` '%e%' ` . But if you have a param like ` $1 ` , it'll
67+ ask you for it every time.
68+
69+ ** NOTE** : this is just a string replacement, and therefore, you can execute
70+ subqueries using this replacement. You can also change the query columns/filters
71+ itself.
0 commit comments