The ui chart can't import data, but you can get the data out of the db and send it to the chart. If you look at the Info tab for the chart node you will find a link to more information which tells you the format of the data you must give it to draw a chart from historical data.
Though I would say that if the ability to draw historical charts is a significant factor then I strongly suggest you look at influxdb and grafana which can easily be integrated with node-red and give very flexible historical (and real-time) graphs.
Unfortunately I cannot use grafana as I am using a 32bit PC.
So I have come back to trying to get database data into ui_chart node.
I have spent all off yesterday to try and understand how to do this, but have not been successful in finding an answer although I have tried many ways !
Firstly I cannot find out what format the ui_chart node requires the data to be formatted as ?
I am using an old version of NodeRED (at the moment everything has been working for years, so do not want to change at this moment, I will in the future)
Keeping things simple I did get this to update a chart
So the data is there, you will just have to figure out how to access the data in msg.payload in the old release you are using. you might try pushing it thru a json node...but I would recommend backing up your system and migrating to the currrent release.