SAP-samples / hana-developer-cli-tool-example

Learn how to build a developer-centric SAP HANA command line tool, particularly designed to be used when performing SAP HANA development in non-SAP tooling (for example from VS Code).
Apache License 2.0
90 stars 24 forks source link

Does not create tables in HDI Container #4

Closed mistyxsap closed 4 years ago

mistyxsap commented 4 years ago

Hi, On running npm start , it does not create the tables in HANA, this is console output

mysaperp@1.0.0 start /home/usr/mysaperp npx cds run

[cds] - model loaded from 2 file(s):

db/schema.cds srv/admin-service.cds

[cds] - connect to db undefined [cds] - serving AdminService { at: '/admin' }

[cds] - launched in: 1321.084ms [cds] - server listening on { url: 'http://localhost:4004' }

logs of hana-cli status Privileges Granted to the Current User PRIVILEGE OBJECT_TYPE GRANTOR IS_GRANTABLE


CREATE ANY SCHEMA SYS TRUE
SELECT SCHEMA MYSAPERP FALSE

My package and default-env.json enable me to connect to HANA express but there are no visible tables when hana-cli tables as well.

jung-thomas commented 4 years ago

Some more details would be helpful. You are building a new CAP project here? I'm guessing so as you are talking about .cds files and and cds run. Are you building/deploying this to HANA? Because CAP run/watch by default would use sqllite not HANA. If so then what commands are you running with the hana-cli tool? Are you connected via a default-env-json? Is that setup with a container technical user or other DB user? What is the default schema in the default-env.json? What command/parameters are you issuing?

mistyxsap commented 4 years ago

My apologies. I am trying to build a CAP Project using the cds init --add HANA connecting to a HANA express DB instance. I have installed the hana-cli . I have configured the hana-cli and a default-env.json in my /home/usr/mysaperp/db directory and can connect to instance using hana-cli status and do get this output among many other this, Roles Granted to the Current User ROLE_SCHEMA_NAME ROLE_NAME GRANTOR IS_GRANTABLE


null PUBLIC SYS FALSE
null MYSAPERP::access_role SYSTEM FALSE
null MYSAPERP::external_privileges_role SYSTEM FALSE

I have installed npm install as per the video in the /home/usr/mysaperp/db and then done the npm start which is when I get the below mysaperp@1.0.0 start /home/usr/mysaperp npx cds run

[cds] - model loaded from 2 file(s):

db/schema.cds srv/admin-service.cds

[cds] - connect to db undefined [cds] - serving AdminService { at: '/admin' }

[cds] - launched in: 1321.084ms [cds] - server listening on { url: 'http://localhost:4004' }

I suspect there is something wrong with my default.json in my /home/usr/mysaperp directory as this is the content of it { "name": "mysaperp", "version": "1.0.0", "description": "A simple CAP project.", "repository": "", "license": "UNLICENSED", "private": true, "dependencies": { "@sap/cds": "^3", "express": "^4", "@sap/hana-client": "^2.4.177" }, "scripts": { "start": "npx cds run" }, "cds": { "requires": { "db": { "kind": "hana" } } } } I do have another one package-lock.json in my /home/usr/mysaperp directory which contains this and much more. { "name": "mysaperp", "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@sap/cds": { "version": "3.33.1", "resolved": "https://npm.sap.com/@sap/cds/-/cds-3.33.1.tgz", "integrity": "sha512-mLSvRba0OlG8jdSb14RF9M2Wbfo19yc4XRqIakCuV1Vs5niXqkeE+COiwNG5TewaXhBsKgD0qDAuiFVm/kGotw==", "requires": { I hope I have given enough info.

jung-thomas commented 4 years ago

Just to be clear, this project is not @sap/cds - that's a separate module/library. We just use it here. For questions about @sap/cds you should really ask elsewhere (the SAP Community Q&A, the current openSAP course on the topic, etc). So if your question is about using cds to create a CAP project, this isn't the correct place for it. This is only for questions directly related to the hana-cli.

mistyxsap commented 4 years ago

I understand Thomas and I appreciate it. I guess my issue was that by I was following the tutorial of hana-cli I would have be able to deploy the cds into HANA but I am unable to so. Hence I raised the issue here.

jung-thomas commented 4 years ago

So you are trying to deploy a cap project. But you said: I have installed npm install as per the video in the /home/usr/mysaperp/db and then done the npm start which is when I get the below mysaperp@1.0.0 start /home/usr/mysaperp npx cds run

npm start in the root of the project is just going to run CDS locally (which will use the local sqlite for persistence). This is just for local testing. What you need to do is a cds build (to generate the deploy time artifacts) and then issue an npm start - and here is the key - in the /db folder. This will start the hdi-deploy module which will send the development artifacts into HANA. Then you will be able to see them with the hana-cli once they are created on the HANA server.

mistyxsap commented 4 years ago

Thanks I will try this.

mistyxsap commented 4 years ago

Some luck. I did have deployed time artifacts in my folder /home/usr/mysaperp/gen/db/src/gen so I did npm install in that folder and then npm start. All good. Thanks mate.