you would need a recordset to return the shipping rate from the database, and a set session value behavior to store the value in a session.
go to the Server Behaviors panel, click the plus button and select eCart -> General -> Set Session Value.
set the trigger to the Recordset not being empty. For the value, click the lightning bolt icon and select the shipping rate column from the recordset. set the name to shipRate
in your shipping rule, change the static rate value to:
$_SESSION['shipRate']