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

SAP CAP project with persistent database: Error - missing localized_* tables

iashishsingh
Participant
8,310

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>
View Entire Topic
chgeo
Product and Topic Expert
Product and Topic Expert

Could you change the `model` property in package.json to

"model": ["db", "srv"]

and try again?

iashishsingh
Participant
0 Likes

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.

chgeo
Product and Topic Expert
Product and Topic Expert

We have analysed the issue and will fix it in the next release (around next week). As a workaround you can revert this commit in the bookshop repository.

Anyways, thanks for reporting!

iashishsingh
Participant
0 Likes

Thanks Christian! Reverting this commit did not solve the error but looking forward the fix in the next release!

jalf1991
Explorer

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" } } }