# Querying data from regularly updating sqlite3 file

**URL:** <https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173>\
**Category:** Help\
**Created:** [April 21, 2024, 1:08pm UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173 "2024-04-21T13:08:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![milianw](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/milianw/32/8813_2.png) [@milianw](https://talk.observablehq.com/u/milianw)\
**Post date:** [April 21, 2024, 1:08pm UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173/1 "2024-04-21T13:08:27Z")

</div>

Hey all,

I want to build a dashboard for a solar panel inverter. This runs from an rpi4 which currently already takes ~15s for the `npm run build` step.

If I understand correctly, I would have to run this step every time my sqlite database changes, to be able to see the new data on the dashboard - is that correct?

Ideally I would be able to simply symlink the “live” sqlite that is getting updated regularly into the `dist` folder at the right position and then get the ability to reload the plot(s) I care about dynamically, similar to how I would be able to do that with a fetch of a remote resource. But I fail to see how that would be possible - is it?

If it isn’t possible, then I fear my only option is to write a thin service wrapper to provide a rest api around the sqlite file, to get regularly updated dashboard contents, correct?

Thanks

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [April 21, 2024, 8:00pm UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173/2 "2024-04-21T20:00:05Z")

</div>

You don’t _have to_ create a data loader, and can access a live file instead. To do this you could use the “hot loading” described in [SQLite | Observable Framework](https://observablehq.com/framework/lib/sqlite) (you just have to make the file accessible by http).

````auto
```js
const db = SQLiteDatabaseClient.open("https://rpi4.local/myfile.sqlite");
```

````

---

<div class="post-metadata">

**Author:** ![milianw](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/milianw/32/8813_2.png) [@milianw](https://talk.observablehq.com/u/milianw)\
**Post date:** [April 22, 2024, 6:55am UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173/3 "2024-04-22T06:55:43Z")

</div>

Right, that would work as long as the database is small I think. Over time I will need to find an alternative solution.

But I’m wondering about how others are handling this - dashboards with live updating data sounds like a niche that observablehq could serve, but it seems like its static nature gets in the way there. Or are there any helpers that allow one to quickly build dynamic data loaders that serve data via an API, to get an effect similar to the live updating `npm run dev` setup?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [April 22, 2024, 8:31am UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173/4 "2024-04-22T08:31:36Z")

</div>

Ah I see. I thought you wanted to access the whole database. I’d recommend setting up this service as an independent API endpoint, which you can do with the usual tools (node + express, or even Apache+PHP…). Then you can read it from a built Framework project, polling with http or streaming on a web socket if you need real-time?

---

<div class="post-metadata">

**Author:** ![milianw](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/milianw/32/8813_2.png) [@milianw](https://talk.observablehq.com/u/milianw)\
**Post date:** [April 22, 2024, 9:33am UTC](https://talk.observablehq.com/t/querying-data-from-regularly-updating-sqlite3-file/9173/5 "2024-04-22T09:33:00Z")

</div>

Thank you for the confirmation. For now reloading the database regularly is fine as it’s still small, giving me time to build a more efficient backend API for this purpose next.

Cheers
