Change value of css root variable at run time

Suppose I’ve a global css file and it contains some variable like this one

/* css */
:root {
–some-variable: 1em;
}

Now I want to change value of css root variable at run time. Actually I want to fetch data from database. How can i achieve this one.