Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
AB
Contributor
cds deploy deploys a given model to a database.

The example below deploys models to the sqlite database myWorkOrder in the directory db
cds deploy --to sqlite:db/myWorkOrder 

The deployment outputs the following information, indicating the database is filled with the initial data in the csv files locates by convention at db/data. Deployment was successful.
> filling jem.mwo.Interactions from db/data/jem.mwo-Interactions.csv 
> successfully deployed to ./db/myWorkOrder

Now we have a persistent database and the package.json is updated accordingly.

From time to time, however, I change my mind and I want to update the initial data and revert to working from memory.

I've found that cds deploy to the special database :memory: deploys to sqlite in memory and updates the package.json accordingly.
cds deploy --to sqlite::memory:

Running this command provides the following output.
> filling jem.mwo.Interactions from db/data/jem.mwo-Interactions.csv 
> successfully deployed to sqlite in-memory db
> updated ./package.json

and the package.json is updated
  "cds": {
"requires": {
"db": {
"kind": "sqlite",
"model": "*",
"credentials": {
"database": ":memory:"
}
}
}
},

This approach allows me to avoid editing package.json manually or remembering to explicitly run from memory. Now I'm free to continue to work in memory until such times as I wish to deploy the model again to a persistent database using the more familiar call.
cds deploy --to sqlite:db/myWorkOrder 

Perhaps you might find this useful.

Update: 24th of June 2021


Using
@sap/cds: 5.1.5
@sap/cds-compiler: 2.2.8
@sap/cds-dk: 4.1.5
@sap/cds-foss: 2.3.1
@sap/cds-runtime: 3.1.2
Node.js: v12.21.0

similar outcomes can be more simply achieved as follows:

Deployment to memory:
cds deploy --to sql

Deployment to persistent database:
cds deploy --to sqlite:/db/myWorkOrder

 

 
1 Comment
Labels in this area