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

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
former_member643578
Participant

Instead of cds run command try the following command

npx nodemon -e cds,csv,properties -w app -w db -x "cds deploy && cds run"

0 Likes

This really does the trick. Thanks!

jasonmuzzy
Active Participant
0 Likes

This really does work, thank you! Can you explain what this command is doing differently than just normal cds deploy followed by cds run?