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,027

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
gregorw
SAP Mentor
SAP Mentor

Hi Kyle,

quite a time ago I've started gregorwolf/cap-postgres. Inpired by the HANA adapter I've made a connection and was able to send the query. But then a mapping of the query result to the CAP format is needed. Maybe you chime in from there.

Best regards
Gregor

0 Likes

Thank you very much, Gregor. I checked out the cap-postgres client you made, and it's an interesting approach. I'd like to take more time to look at and see if I can get it to work.

Thanks again,

Kyle

gregorw
SAP Mentor
SAP Mentor
0 Likes

Hi kturske-pmc,

please follow the Create PostgreSQL adapter #88 to help us create the adapter as soon as it's possible.

Best regards
Gregor

gregorw
SAP Mentor
SAP Mentor

Hi kturske-pmc,

hope you've seen the announcement of cds-pg. Looking forward for your contributions and maybe other database adapters.

Best regards
Gregor