SAP HANA Database Explorer VSCode Extension Getting Started Tips
You might have seen that SAP just recently released the first version of SAP HANA Database Explorer as a Visual Studio Code Extension. You can get that extension here: SAP HANA Database Explorer – Visual Studio Marketplace
For those of us that do a lot of local development in VSCode, even this early version with limited functionality is a welcome addition. In this blog post I wanted to share with you a few tricks and tips I picked up from first using the tool today.
Check the CF URL Endpoint
If you have the Cloud Foundry CLI installed, then the extension will use it to automatically determine the Database Explorer endpoint and fill the SAP HANA Database Explorer Connections section of the tool for you. But when I first started the extension I got a Not Authorized error. It happens that I use multiple SAP BTP regions (EU10 and US10) and the extension was trying to connect to EU10 when my HANA Cloud instances and Database Explorer were all running in US10.
You can update this setting manually from the VSCode Preferences however. Use File->Preferences->Settings.
Then open the Extensions folder and find the SAP HANA Database Explorer section. There is a entry there where you can manually set or override the SAP HANA Database Explorer:
As soon as I updated the region in the URL to the correct one for my setup, the authentication errors disappeared and all the connections that I had configured previously in the SAP HANA Database Explorer web interface were immediately added to my extension.
This extension also lets you directly configure connections locally. And I thought great, I have lots of connections that I have configured locally for development using default-env.json files. I can just take the configuration details from a default-env.json or use “cf env” to get service binding details. That should provide everything that I need to setup a manual connection in this tool.
However one small issue I found was a difference in the formatting expected for the certificate of the connection. In the cf environment and in the default-env.json the certificate has a —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—– section. However when I included the complete certificate in the VSCode Extension it reported an error that it was invalid. As soon as I removed the BEGIN and END section of the certificate, it validated and worked perfectly fine.
With those setup learnings out of the way, I was off and using the extension with both direct Schema connections and HDI container connections. It might mostly be the SQL Console for now, but even this is a nice addition to the workflow of local development in VSCode.
As of February 4th 2022, we updated the hana-cli tool to help out here. We added the dbx output option to the systemInfo command which will read an existing connection and format and present the connect ready to use in the DBX VSCode Extension. This includes the stripping of the begin and end certificate.