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>
Request clarification before answering.
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.
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.