{"id":6315,"date":"2024-03-22T12:04:04","date_gmt":"2024-03-22T11:04:04","guid":{"rendered":"https:\/\/www.ho2-gmbh.de\/news\/external-access-to-your-postgresql-database-on-the-btp-ho2-shows-how-its-done\/"},"modified":"2024-04-09T16:48:51","modified_gmt":"2024-04-09T14:48:51","slug":"external-access-to-your-postgresql-database-on-the-btp-ho2-shows-how-its-done","status":"publish","type":"post","link":"https:\/\/www.ho2-gmbh.de\/en\/news\/external-access-to-your-postgresql-database-on-the-btp-ho2-shows-how-its-done\/","title":{"rendered":"External access to your PostgreSQL database on SAP BTP? HO2 shows how it&#8217;s done"},"content":{"rendered":"<h1>External Access to PostgreSQL Database Instances on SAP BTP with HO2<\/h1>\n<p>Are you ready to take your database management to the next level? As part of the <strong>InnovateSAP<\/strong> initiative, we want to help you effectively overcome the challenges of accessing PostgreSQL database instances on SAP BTP.<\/p>\n<h2>Starting situation<\/h2>\n<p>As a database specialist or software developer, it is quite common to have direct access to the databases. Even if this does not seem absolutely necessary, for example, in the context of <a href=\"https:\/\/www.ho2-gmbh.de\/news\/entdecke-mit-uns-die-moeglichkeiten-von-sap-cap\/\">SAP CAP application development<\/a> .<\/p>\n<p>However, access can be helpful or crucial in many situations and also in day-to-day operations. Think of areas such as data migration, debugging, monitoring, and performance optimization.<\/p>\n<p>Access to PostgreSQL database instances was a significant hurdle here. By default, SAP does not provide an application to manage PostgreSQL instances. The ability to view tables, data, and other objects and, if necessary, modify them was limited compared to the options available with <a href=\"https:\/\/www.ho2-gmbh.de\/news\/sap-hana-cloud-skalierbarkeit-und-flexibilitaet-fuer-dein-business\/\">HANA-DB<\/a> on <a href=\"https:\/\/www.ho2-gmbh.de\/news\/btp-serviceueberblick-mit-use-cases\/\">SAP BTP<\/a>. This limitation required a solution to improve efficiency and functionality.<\/p>\n<h2><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-jpg.webp\"><img data-dominant-color=\"7a9d8b\" data-has-transparency=\"false\" style=\"--dominant-color: #7a9d8b;\" decoding=\"async\" class=\"alignnone size-medium wp-image-6303 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-480x480.webp\" alt=\"PostgreSQL inaccessible on the BTP\" width=\"480\" height=\"480\" data-wp-pid=\"6303\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-480x480.webp 480w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-150x150.webp 150w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-768x768.webp 768w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-350x350.webp 350w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-jpg-1200x1200.webp 1200w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgres-locked-on-btp-jpg.webp 1024w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><\/h2>\n<h2>Approach<\/h2>\n<p>To ensure the security and accessibility of the database for developers and database specialists, our team decided to set up an <strong>SSH tunnel<\/strong> . By deploying a small application, such a connection was successfully established. As a result, we were able to implement an efficient and secure solution for external database access.<\/p>\n<h2>Howto: SAP BTP PostgreSQL Database Connection to pgAdmin with SSH Tunnel<\/h2>\n<p>This guide provides you with an in-depth guide to establish a secure and direct connection between your SAP BTP hosted PostgreSQL database and the pgAdmin application on your local machine.<\/p>\n<h3>Preconditions:<\/h3>\n<ul>\n<li>SAP BTP Account<\/li>\n<li><a href=\"https:\/\/www.pgadmin.org\/download\/\" target=\"_blank\" rel=\"noopener\">pgAdmin<\/a> installed on your computer<\/li>\n<li>Authorization and quota to create a PostgreSQL-DB instance, to create applications for deploys and bindings<\/li>\n<li>Cloud Foundry CLI installed<\/li>\n<\/ul>\n<h3>Steps for external access:<\/h3>\n<ol>\n<li>Create a PostgreSQL database instance on SAP BTP.<\/li>\n<li>Create a new service key for external access. The key data is required for the tunnel and the admin software<\/li>\n<li>Log in to Cloud Foundry using the command line.<\/li>\n<li>Deployment of the sshenable app.<\/li>\n<li>Bind the PostgreSQL database to the app.<\/li>\n<li>Open an SSH tunnel for local database access.<\/li>\n<li>Configuration of pgAdmin to access the SAP BTP PostgreSQL database.<\/li>\n<\/ol>\n<h3>1.Create PostgreSQL Database Instance on SAP BTP<\/h3>\n<p>If all requirements are met, only the name of the instance needs to be assigned. You should avoid unusual signs:<\/p>\n<p><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgreSQL-instanz-anlegen-jpg.webp\"><img data-dominant-color=\"1e2329\" data-has-transparency=\"false\" style=\"--dominant-color: #1e2329;\" decoding=\"async\" class=\"alignnone size-medium wp-image-6295 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgreSQL-instanz-anlegen-640x364.webp\" alt=\"Create postgreSQL instance\" width=\"640\" height=\"364\" data-wp-pid=\"6295\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgreSQL-instanz-anlegen-640x364.webp 640w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgreSQL-instanz-anlegen-1920x1091.webp 1920w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/postgreSQL-instanz-anlegen-768x436.webp 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3>2.Create a new service key for external access<\/h3>\n<p><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-jpg.webp\"><img data-dominant-color=\"22262e\" data-has-transparency=\"false\" style=\"--dominant-color: #22262e;\" decoding=\"async\" class=\"size-medium wp-image-6297 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-640x352.webp\" alt=\"\" width=\"640\" height=\"352\" data-wp-pid=\"6297\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-640x352.webp 640w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-1920x1057.webp 1920w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-768x423.webp 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-jpg.webp\"><img data-dominant-color=\"272d33\" data-has-transparency=\"false\" style=\"--dominant-color: #272d33;\" decoding=\"async\" class=\"alignnone size-medium wp-image-6299 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-640x441.webp\" alt=\"\" width=\"640\" height=\"441\" data-wp-pid=\"6299\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-640x441.webp 640w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-1857x1280.webp 1857w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-768x529.webp 768w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/createServiceKey-credentials-jpg.webp 2027w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><strong>The data is required for the tunnel and the DB admin software<\/strong><\/p>\n<h3>3. To log in to the Cloudfoundry:<\/h3>\n<p><strong>From now on we need the command line<\/strong><\/p>\n<pre><code>cf login --sso<\/code><\/pre>\n<p>or<\/p>\n<pre><code>cf api API_ENDPOINT \ncf login<\/code><\/pre>\n<p>A possible API endpoint is: https:\/\/api.cf.us10-001.hana.ondemand.com. The URL depends on your subaccount.<\/p>\n<h3>4. To deploy the &#8220;SSH Enable&#8221; APP:<\/h3>\n<pre><code>git clone https:\/\/github.com\/alimert801\/cf-sample-python-app.git<\/code><\/pre>\n<p>optionally change the app name(APP_NAME) from myapp to sshenable in the manifest.yml <\/p>\n<p>In the root folder of the app, run (replace APP_NAME):<\/p>\n<pre><code>cf push APP_NAME<\/code><\/pre>\n<p>Share the app as an SSH endpoint and restart:<\/p>\n<pre><code>cf enable-ssh APP_NAME<\/code><\/pre>\n<pre><code>cf restage APP_NAME<\/code><\/pre>\n<h3>5. Bind the PostgreSQL database to the app<\/h3>\n<h3><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-jpg.webp\"><img data-dominant-color=\"232830\" data-has-transparency=\"false\" style=\"--dominant-color: #232830;\" decoding=\"async\" class=\"alignnone size-medium wp-image-6301 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-640x429.webp\" alt=\"binding of the DB to the APP\" width=\"640\" height=\"429\" data-wp-pid=\"6301\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-640x429.webp 640w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-1910x1280.webp 1910w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-768x515.webp 768w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/binding-der-DB-zur-APP-jpg.webp 1986w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/h3>\n<h3>6. To create the SSH tunnel:<\/h3>\n<pre><code>cf ssh -L localhost:2641:REMOTEHOST:REMOTEPORT APP_NAME -N <\/code><\/pre>\n<p>In this command, the (arbitrarily chosen) local port 2641 is forwarded to the PostgreSQL database port of the SAP BTP, which allows pgAdmin to access your SAP BTP database as if it were local. REMOTEHOST and REMOTEPORT can be found in the service key created at the beginning as host and port<\/p>\n<h3>7. Configuring pgAdmin:<\/h3>\n<p>Four values are required from the service key:<\/p>\n<ol>\n<li><strong>dbname<\/strong><\/li>\n<li><strong>Password<\/strong><\/li>\n<li><strong>port<\/strong><\/li>\n<li><strong>username<\/strong><\/li>\n<\/ol>\n<p><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/pgAdmin-4-537x480.png\" rel=\"prettyPhoto[gallery-s6sQ]\"><img data-dominant-color=\"eef0f4\" data-has-transparency=\"true\" style=\"--dominant-color: #eef0f4;\" decoding=\"async\" class=\"size-medium wp-image-6288 has-transparency\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/pgAdmin-4-537x480.png\" alt=\"\" width=\"537\" height=\"480\" data-wp-pid=\"6288\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/pgAdmin-4-537x480.png 537w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/pgAdmin-4-768x686.png 768w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/pgAdmin-4.png 1390w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/a><\/p>\n<p>It is not necessary to take care of the SSH tab!<\/p>\n<h3>Architecture:<\/h3>\n<p>This architecture enables seamless communication and secure data access between your on-premises work environment and SAP BTP. By binding the database to your cloud application and using an SSH tunnel to route the ports, you create a secure and efficient data bridge directly in pgAdmin on your local machine.<\/p>\n<h2>Results<\/h2>\n<p>By implementing this solution, access to the PostgreSQL database instances is enabled. Tools such as pgAdmin and SQL Workbench\/J can now be used to manage the database efficiently. This improvement has brought significant improvements in areas such as data migration, debugging, monitoring, and performance optimization.<\/p>\n<h2><a href=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-jpg.webp\"><img data-dominant-color=\"677165\" data-has-transparency=\"false\" style=\"--dominant-color: #677165;\" decoding=\"async\" class=\"alignnone size-medium wp-image-6307 not-transparent\" src=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-480x480.webp\" alt=\"Developer access to PostgreSQL\" width=\"480\" height=\"480\" data-wp-pid=\"6307\" data-pin-nopin=\"nopin\" srcset=\"https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-480x480.webp 480w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-150x150.webp 150w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-768x768.webp 768w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-350x350.webp 350w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-jpg-1200x1200.webp 1200w, https:\/\/www.ho2-gmbh.de\/wp-content\/uploads\/2024\/03\/dev-access-to-postgreSQL-jpg.webp 1024w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><\/h2>\n<h2>Closing remarks<\/h2>\n<p>The HO2 as part of the <strong>InnovateSAP<\/strong> initiative has once again demonstrated the results that can be achieved through technical expertise. With this enabled database accessibility, we are setting new standards in efficiency and productivity.<\/p>\n<p>If you have any questions about the implementation or other services, do not hesitate to contact us. We are ready to tackle any challenge and seize every opportunity to innovate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Discover how HO2 enables remote access to Postgre&#8217;s database instances on SAP BTP, taking data management, monitoring, and performance optimization to the next level.<\/p>\n","protected":false},"author":1,"featured_media":6306,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wpupg_custom_link":[],"wpupg_custom_link_behaviour":[],"wpupg_custom_link_nofollow":[],"wpupg_custom_image":[],"wpupg_custom_image_id":[],"footnotes":""},"categories":[511,497],"tags":[723,728,722,727,729,730,725,731,721,510,726,724],"class_list":{"0":"post-6315","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-sap-btp-en","8":"category-sap-code-en","9":"tag-database-management","10":"tag-debugging-en","11":"tag-external-access","12":"tag-migration","13":"tag-monitoring-en","14":"tag-performance-optimization","15":"tag-pgadmin-en","16":"tag-postgres-en","17":"tag-postgresql-en","18":"tag-sap-btp-en","19":"tag-sql-workbench-j-en","20":"tag-ssh-tunnel-en"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>External access to your PostgreSQL database on SAP BTP? HO2 shows how it&#039;s done - HO2 Systemberatung GmbH<\/title>\n<meta name=\"description\" content=\"Revolutionize your data management with secure external access to PostgreSQL instances. Discover the possibilities at SAP BTP!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ho2-gmbh.de\/en\/news\/external-access-to-your-postgresql-database-on-the-btp-ho2-shows-how-its-done\/\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"External access to your PostgreSQL database on SAP BTP? HO2 shows how it's done - HO2 Systemberatung GmbH","description":"Revolutionize your data management with secure external access to PostgreSQL instances. Discover the possibilities at SAP BTP!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ho2-gmbh.de\/en\/news\/external-access-to-your-postgresql-database-on-the-btp-ho2-shows-how-its-done\/","schema":{"@context":"https:\/\/schema.org","@graph":[]}},"_links":{"self":[{"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/posts\/6315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/comments?post=6315"}],"version-history":[{"count":1,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/posts\/6315\/revisions"}],"predecessor-version":[{"id":6390,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/posts\/6315\/revisions\/6390"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/media\/6306"}],"wp:attachment":[{"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/media?parent=6315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/categories?post=6315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ho2-gmbh.de\/en\/wp-json\/wp\/v2\/tags?post=6315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}