cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Connect to any database (MySQL, Postgres, MariaDB) using CAPM for JavaScript

0 Likes
3,030

I have gone through the tutorial for the CDS CAPM:

https://developers.sap.com/tutorials/cp-apm-nodejs-create-service.html

--and--

https://developers.sap.com/tutorials/cap-service-deploy.html

Now, I am wondering if there would be any sort of way to expose different types of databases (e.g. PostgreSQL, MySQL, MariaDB, etc.) instead of just SQLite and Hana. The reason why I want to use a database other than these two is that I do not have direct access to Hana and I want something that is somewhat similar to Hana for the sake of testing. Anyways, I am currently using Postgres for my test database because I already have a Docker container with an instance of Postgres running inside of it. Anyways, this is how I have my package.json set up:

"cds": {
    "requires": {
      "db": {
        "kind": "pg",
        "model": [
          "db",
          "srv"
        ],
        "credentials": {
          "url": "127.0.01",
          "port": "5432",
          "database": "postgres",
          "username": "postgres",
          "password": "PGPASSWORD"

        }
      }
    }
  }

I currently have the npm package "pg" installed which is a Postgres client for Node.js. I have tried both "cds watch" and "cds deploy" Now there doesn't seem to be a deployer module for this use case unless there is a step I am missing. Any sort of direction on where to go would be extremely helpful.

Thank you everyone!

View Entire Topic
vobu
Active Contributor

hi kyle,

what you're trying to do is sth we've been bothering the CAP core team with from the very beginning: support for persistence sfw other than HANA & SQLite. Due to CAP treating cf as its' birthplace, this is unfortunately the status quo.

But CAP is designed in a modular fashion, so plugging in other DB adapters is technically possible. As soon as Daniel H (CAP papa) has walked us through the internal code base at reCAP and as soon as CAP itself is Open Source, many of us are on their heels of jumping to the occasion for providing CAP persistence modules for Postgres and the like.

Keep your fingers crossed!

Best, V.