on 2020 Feb 18 5:23 AM
Hello,
I am trying to run the sample bookshop app provided in the SAP CAP samples(https://github.com/SAP-samples/cloud-cap-samples). It runs as expected when using the default in-memory sqlite database (which is the default setting). If I try to change the settings to use a persistent sqlite database, the services are throwing errors of form:
SQLITE_ERROR: no such table: localized_<service-name>_<entitiy-name>
http://localhost:4004/browse/Books
<error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
<code>500</code>
<message>SQLITE_ERROR: no such table: localized_CatalogService_Books</message>
</error>
Following is a step by step detail of what I've done. Any insight into what might be going wrong and how to fix it would be very much appreciated. Thanks!
Clone sample apps from https://github.com/SAP-samples/cloud-cap-samples
cd cloud-cap-samples/
npm i
npm run bookshop
The default configuration runs the sqlite database in-memory. In order to use the persistent database, do following changes:
cd packages/bookshop
cds deploy --to sqlite:my.db
The cds deploy command will create a persistent database and fill the necessary tables using sample CSV data files. It also updates the package.json with cds configuration to use a persistent database instead of the default in-memory database. You should see console messages like following:
> filling sap.capire.bookshop.Authors from db/data/sap.capire.bookshop-Authors.csv
> filling sap.capire.bookshop.Books from db/data/sap.capire.bookshop-Books.csv
> filling sap.capire.bookshop.Books_texts from db/data/sap.capire.bookshop-Books_texts.csv
> filling sap.capire.bookshop.OrderItems from db/data/sap.capire.bookshop-OrderItems.csv
> filling sap.capire.bookshop.Orders from db/data/sap.capire.bookshop-Orders.csv
> filling sap.common.Currencies from db/data/sap.common-Currencies.csv
> filling sap.common.Currencies_texts from db/data/sap.common-Currencies_texts.csv
/> successfully deployed to ./my.db
> updated ./package.json
The package.json should have an updated "cds" section as follows -
"cds": {
"requires": {
"db": {
"kind": "sqlite",
"model": "db/schema.cds",
"credentials": {
"database": "my.db"
}
}
}
}
Now, if we trigger command 'cds run', the cds should start serving using the persistent database.
cds run
[cds] - connect to datasource - sqlite:my.db
[cds] - serving AdminService at /admin
[cds] - serving CatalogService at /browse - with impl: srv/cat-service.js
[cds] - service definitions loaded from:
app/index.cds
srv/admin-service.cds
srv/cat-service.cds
app/admin/fiori-service.cds
app/browse/fiori-service.cds
app/orders/fiori-service.cds
app/common.cds
db/schema.cds
../../node_modules/@sap/cds/common.cds
[cds] - launched in: 1303.835ms
[cds] - server listening on http://localhost:4004
Now, if you go to link http://localhost:4004/browse/Books, it shows following error:
<error xmlns="http://docs.oasis-open.org/odata/ns/metadata">
<code>500</code>
<message>SQLITE_ERROR: no such table: localized_CatalogService_Books</message>
</error>
Could you change the `model` property in package.json to
"model": ["db", "srv"]
and try again?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian. Thanks for your suggestion! I tried changing it to
"model": ["db", "srv"]
but getting the same error as before. To make it easier for the error to be reproduced, I've pushed my changes under a fork of cloud-cap-samples repo here: https://github.com/git-ashish/cloud-cap-samples. The changes have been made to packages/bookshop folder.
Thanks.
Thanks Christian! Reverting this commit did not solve the error but looking forward the fix in the next release!
Hi @christian.georgi
the issue is with this package.json file. I delete this lines in the json and all run fine:
"requires": { "db": { "kind": "sqlite", "model": [ "db", "srv" ], "credentials": { "database": "sqlite.db" } } }
Instead of cds run command try the following command
npx nodemon -e cds,csv,properties -w app -w db -x "cds deploy && cds run"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Ashish,
Thanks for reporting this issue, it seems like a bug!
Which version of `@sap/cds` are you using? You can find this information by typing `cds -v`.
I tested it with `@sap/cds: 3.21.3` and it works fine.
Thanks and best regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
Thanks for your quick reply!
My machine also has the same 3.21.3 version. Here is the output of `cds -v`:
@sap/cds-dk: 1.4.4
@sap/cds: 3.21.3
@sap/cds-compiler: 1.21.1
@sap/cds-foss: 1.1.0
@sap/cds-messaging: 1.5.0
@sap/cds-reflect: 2.9.2
@sap/cds-rest: 1.3.0
@sap/cds-services: 1.22.0
@sap/generator-cds: 2.11.1
Node.js: v10.16.0<br>
The bookshop/package.json has "@sap/cds": "latest" under "dependencies".
Sorry, I did not clearly understand you. Is it a bug in cds or does it look like a setup issue at my end?
Thanks David!
Some additional information:
If I deploy the same app to SAP HANA cloud using the guide: https://cap.cloud.sap/docs/advanced/deploy-to-cloud, the service works fine as expected. The issue appears to be occurring when using the persistent database as sqlite.
Hi,
i have similar issues after deployment to CFm but just using in-memory db!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.