@saptools/sqltools
A command line that turns the HANA service binding of a Cloud FoundrySAP BTP, Cloud Foundry RuntimeThe Cloud Foundry runtime of SAP BTP: memory for applications in a Cloud Foundry org, run from SAP's Java, Node.js and Python buildpacks or community buildpacks and managed with the standard Cloud Foundry tools.sap official, btp app into a connection for the SQLTools extension in VS Code, written to the workspace's .vscode/settings.json.
Connecting the SQLTools extension in VS Code to an app's database otherwise means copying host, user, password and schema out of VCAP_SERVICES by hand. sqltools-export reads the bindings from a live app (from-app logs in with SAP_EMAIL and SAP_PASSWORD, from-cf uses the current cf target), from a saved JSON file or from stdin, and writes a SAPHana connection named <app> (<region>) together with a hana-credentials.json backup of every binding, both holding live credentials. It writes the connection and stops there: queries run in the SQLTools extension and the SQLTools SAP HANA driver, which have to be installed. Only bindings under the hana service label are read, the default for SAP HANA CloudSAP HANA CloudThe managed database under most of this: CAP's default target, the store Datasphere and Analytics Cloud sit on, and a service with plans and components.sap official, btp and HDI bindings on BTP.
Facts
Where it sits
Who is behind it
In the atlas: maintains 18, contributes to 18@dongitranmaintainer
What it declares
Every artifact
- Type
- CLI
- Origin
- Independently maintained
- Runs on
- Cloud Foundry
As a CLI
- Distributed through
- npm
Connections
Editor help with source: completion, navigation, errors, refactoring
A cross-platform JavaScript runtime that servers, command line tools and scripts written in JavaScript are run with. For the things here, the prerequisite a repository names when its build is a set of npm scripts.
Managed SAP HANA database service on BTP
Download
Install
npm add @saptools/sqltoolsDerived from the package name. No recipe recorded; the README has the configuration.
Architecture
Download
README
quoted from dongitran/saptools under MIT, read🗄️ @saptools/sqltools
Stop copy-pasting HANA credentials out of VCAP_SERVICES.
One command turns a SAP BTP Cloud Foundry HANA service binding into a ready-to-use VS Code SQLTools connection — no cockpit clicking, no JSON surgery.
Install • Quick Start • CLI • FAQ
✨ Features
- 🔌 One-shot export — pulls
VCAP_SERVICESfrom any CF app and writes.vscode/settings.jsonwith a valid SAPHana connection - 🪄 Four input paths — read from a real CF app, a saved JSON file, stdin, or an already-targeted CF session
- 🧷 Non-destructive — preserves unrelated VS Code settings and, with
--merge, unrelated SQLTools connections too - 💾 Backup JSON — drops a
hana-credentials.jsonbeside the settings so HDI users / URLs / certificates stay within reach - 🔒 Type-safe — shipped with full TypeScript definitions for every input and output shape
- 🪶 Tiny — two runtime deps (
@saptools/cf-sync,commander) and zero runtime magic
📦 Install
# Global CLI
npm install -g @saptools/sqltools
# Or as a dependency
npm install @saptools/sqltools
# pnpm add @saptools/sqltools
# yarn add @saptools/sqltools
Note
Requires Node.js ≥ 20. The
from-cf/from-appcommands also need thecfCLI onPATH. Forfrom-app, setSAP_EMAILandSAP_PASSWORDso the tool can authenticate and target the org/space for you.
Updates
Every command first checks npm for a newer @saptools/sqltools (at most once an hour, one small request
with a 2-second timeout) and, when one exists, installs that exact version with the package manager
that owns the running binary and re-runs the command you typed on the new version. Both steps are
announced on stderr; nothing is printed when the install is already current:
sqltools-export: updating 0.2.0 -> 0.3.0 ...
sqltools-export: updated to 0.3.0; re-running the command
If the install cannot complete, one stderr line gives the manual command and the command runs on the
installed version; that version is not retried for a day. sqltools-export self-update forces the check and
install now; sqltools-export self-update --check only reports.
| Control | Effect |
|---|---|
SAPTOOLS_AUTO_UPDATE=on|notify|off | on (default) installs and re-runs; notify prints the manual command once per version; off never checks. Applies to every @saptools CLI. |
SQLTOOLS_AUTO_UPDATE | same values, this CLI only; wins over the global variable |
SAPTOOLS_UPDATE_INTERVAL_MINUTES | minutes between checks (default 60; 0 checks on every run) |
SAPTOOLS_NPM_REGISTRY | registry to check and install from (default: npm's configured registry, then npmjs) |
SAPTOOLS_UPDATE_DEBUG=1 | explain on stderr why nothing happened |
The updater switches itself off in CI (CI set), under NODE_ENV=test or NO_UPDATE_NOTIFIER, when
the binary runs from a source checkout, an npm link or an npx cache, and inside the re-run itself.
It never writes to stdout, never asks for input, never uses sudo, and never moves onto a prerelease.
Its state lives in ~/.saptools/updates/.
🚀 Quick Start
# Already logged in and targeted with `cf login`? One command is enough.
sqltools-export from-cf \
--app my-srv --region eu10 --org my-org --space dev
Result:
✔ Updated SQLTools connections (1) → /workspace/.vscode/settings.json
Credentials JSON saved → /workspace/hana-credentials.json
• my-srv (eu10) host.hana.ondemand.com:443 schema=SCHEMA_MY_SRV
Open the workspace in VS Code, install the SQLTools + SQLTools SAP HANA driver extensions, and the new connection is already wired up.
🧰 CLI
Every command identifies an app with the same four labels — they are written into the SQLTools connection name as "<app> (<region>)".
| Flag | Description | Example |
|---|---|---|
--app <name> | CF app name (also the label) | my-srv |
--region <key> | CF region key | ap10, eu10, us10 |
--org <name> | CF org name | my-org |
--space <name> | CF space name | dev |
Common output options:
| Flag | Description |
|---|---|
--cwd <dir> | Workspace root that owns .vscode/settings.json (default: cwd) |
--merge | Merge with existing connections by name (default: overwrite) |
--credentials-out <path> | Custom path for the backup JSON |
--no-credentials-file | Skip writing hana-credentials.json |
🌐 sqltools-export from-app
Full end-to-end: cf api → cf auth → cf target → cf env → write settings. Great for CI and fresh machines.
export SAP_EMAIL="you@company.com"
export SAP_PASSWORD="your-sap-password"
sqltools-export from-app \
--app my-srv --region eu10 --org my-org --space dev
📡 sqltools-export from-cf
Assumes you are already targeted (cf login && cf target -o ... -s ...). Shells out to cf env <app> and writes the settings.
sqltools-export from-cf --app my-srv --region eu10 --org my-org --space dev
📄 sqltools-export from-file
Already have a VCAP_SERVICES JSON saved somewhere? Point to it.
sqltools-export from-file --input ./vcap.json \
--app my-srv --region eu10 --org my-org --space dev
📥 sqltools-export from-stdin
Classic pipe:
cf env my-srv | jq '."VCAP_SERVICES"' | sqltools-export from-stdin \
--app my-srv --region eu10 --org my-org --space dev
🔁 sqltools-export convert
Print a single SQLTools connection JSON to stdout — no files written. Perfect for scripting.
sqltools-export convert --input ./vcap.json \
--app my-srv --region eu10 --org my-org --space dev
Tip
Use
--mergeto keep hand-crafted connections in.vscode/settings.jsonuntouched while only overwriting the one matching<app> (<region>).
📁 Output Files
After a successful export you get two files in the workspace root:
.vscode/settings.json # SQLTools connections + sqltools.useNodeRuntime
hana-credentials.json # Backup of every extracted binding (HDI user, URL, cert…)
🔬 Shape of the SQLTools connection entry
{
"sqltools.useNodeRuntime": true,
"sqltools.connections": [
{
"name": "my-srv (eu10)",
"driver": "SAPHana",
"server": "host.hana.ondemand.com",
"port": 443,
"username": "USER_1",
"password": "…",
"database": "SCHEMA_MY_SRV",
"connectionTimeout": 30,
"previewLimit": 50,
"hanaOptions": {
"encrypt": true,
"sslValidateCertificate": true,
"sslCryptoProvider": "openssl"
}
}
]
}
Important
Both files contain live HANA credentials. They live inside your workspace, not under
~— keep them out of git (add to.gitignoreif your repo doesn't already excludehana-credentials.json).
❓ FAQ
Do I still need the SQLTools SAP HANA driver extension?
Yes. @saptools/sqltools only writes the connection definition. You still need the SQLTools extension and the SQLTools SAP HANA driver to actually run queries.
Will this overwrite my other connections in settings.json?
By default, yes — sqltools.connections is replaced with the newly-exported entries, while every other key in settings.json is preserved. Pass --merge to keep existing connections whose name does not match <app> (<region>).
Is the backup file safe to commit?
No. hana-credentials.json contains the HANA password, schema, HDI user, and the certificate payload. Add it to .gitignore.
What does the CLI do with SAP_EMAIL / SAP_PASSWORD?
They are only read by from-app. The tool forwards them directly to cf auth — no storage, no logging. from-cf assumes you are already targeted and ignores both env vars.
My binding is not called hana in VCAP_SERVICES. Does this still work?
Not yet. The parser looks for the hana service label (the default for SAP HANA Cloud / HDI service bindings on BTP). If you have a bespoke label, open an issue and we'll add support.
🛠️ Development
From the monorepo root:
pnpm install
pnpm --filter @saptools/sqltools... build
pnpm --filter @saptools/sqltools typecheck
pnpm --filter @saptools/sqltools lint
pnpm --filter @saptools/sqltools test:unit
pnpm --filter @saptools/sqltools test:e2e:fake
pnpm --filter @saptools/sqltools test:e2e:live # needs SAP_EMAIL / SAP_PASSWORD
The live e2e suite auto-discovers a real CF app with a hana service binding by scoring candidates from ~/.saptools/cf-structure.json (populated by cf-sync). To pin a specific target:
export E2E_TARGET="eu10/my-org/my-space/my-srv"
Live e2e only performs read-only CF operations (cf api, cf auth, cf target, cf env) — nothing is created, updated, or deleted in Cloud Foundry.
🌐 Related
- 📦
@saptools/cf-sync— sync the CFregion → org → space → apptree to disk - 🔐
@saptools/cf-xsuaa— fetch XSUAA client credentials and OAuth2 tokens - 🗂️ saptools monorepo — the full toolbox
👨💻 Author
dongtran ✨
📄 License
MIT
Made with ❤️ to make your work life easier!
History
Others providing
Compare all 4 on the Editor support page →- SAP Build CodeSAP Build CodeSAP's development environment on BTP for SAPUI5, SAP Fiori, mobile and CAP applications that run on the SAP BTP, Cloud Foundry Runtime, in which Joule generates models, services, logic, tests and apps.sap official, btpDevelopment environment on BTP for UI5, Fiori, mobile and CAP
- SAP Business Application StudioSAP Business Application StudioSAP's development environment for business applications, delivered as a cloud service and opened in a browser, where work happens in preconfigured dev spaces.sap official, btpBrowser-based development environment with dev spaces
- SAP Web IDE Full-StackSAP Web IDE Full-StackSAP's IDE service on BTP for SAPUI5 and SAP Fiori apps, full-stack SaaS applications, SAP S/4HANA extensions, hybrid mobile apps and IoT apps, with an SDK for extending the IDE itself.sap official, btpIDE service on SAP BTP for SAPUI5, Fiori and full-stack apps
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:saptools-sqltools- JSON
- /artifacts/saptools-sqltools.json
- MCP
- Connecting an agent