Skip to Content
Technical Articles

cds deploy to sqlite in-memory database

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.
 

 

1 Comment
You must be Logged on to comment or reply to a post.