Discussion Forum

Populating the DB from schema

In C++ I have this code that creates a table in a SQL database and then inserts values inside it.

add_structure(“CREATE TABLE smem_constants_store (smem_act_max REAL, smem_act_low REAL)”);
add_structure(“INSERT OR IGNORE INTO smem_constants_store (smem_act_max, smem_act_low) VALUES (9223372036854775807, -1000000000)”);
add_structure(“INSERT OR IGNORE INTO smem_constants_store (smem_act_max, smem_act_low) VALUES (9223372036854775808, -1000000000)”);

I am guessing the schema for this would be:

smem_constants_store sub entity,
has smem_act_max,
has smem_act_low,
smem_act_max sub attribute, value double,
smem_act_low sub attribute, value double;

How do I insert the values from the schema?

you’d probably want to generate something like:

insert $x isa smem_constants_store, has smem_act_max 9223372036854775808, has smem_act_low -1000000000;

How to insert data for a particular schema is covered in our docs at docs.vaticle.com