# Project cloud database

**URL:** <https://forum.pioreactor.com/t/project-cloud-database/135>\
**Category:** API & Data Access\
**Tags:** feature\
**Created:** [June 30, 2023, 3:41pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135 "2023-06-30T15:41:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/martin/32/66_2.png) [@Martin](https://forum.pioreactor.com/u/Martin)\
**Post date:** [June 30, 2023, 3:41pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/1 "2023-06-30T15:41:11Z")

</div>

How difficult would it be to set up an automated means of sending run data from multiple users to a central project database?

For example, when collaborating on open data projects, it would be amazing if anyone interested could analyse and visualise large data sets from multiple contributors.

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [June 30, 2023, 6:09pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/2 "2023-06-30T18:09:32Z")

</div>

Hi @Martin

I don’t think this would be very difficult at all, actually. Certainly it would use the plugin system, and all users would install the plugin and add the right DB credentials on their local system.

Are you thinking the data should arrive in realtime (ex: to be displayed and graphed in a UI) to the central database? Or batched in data dumps?

---

<div class="post-metadata">

**Author:** ![Martin](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/martin/32/66_2.png) [@Martin](https://forum.pioreactor.com/u/Martin)\
**Post date:** [June 30, 2023, 7:32pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/3 "2023-06-30T19:32:32Z")

</div>

Hi @CamDavidsonPilon

That’s excellent news. While I was originally thinking that the data would be sent at the conclusion of each experiment, the realtime idea has a lot of advantages:

- You could have people across different timezones looking after your experiments while you sleep.
- People who don’t yet have Pioreactors could still engage in live experiments
- You could do remote teaching where the students are able to manipulate the data and make suggestions during the live experiment.
- If your lab was sabotaged the data would be safely stored offsite
- We could build Pioreactor digital twins

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [June 30, 2023, 7:58pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/4 "2023-06-30T19:58:04Z")

</div>

Here’s an outline of a few ways realtime could be done:

### Using MQTT (no Python, but lots of networking)

The Pioreactor uses Mosquitto, a software that implements MQTT, for realtime data streams. A Mosquitto broker lives on the leader in each [Pioreactor cluster](https://docs.pioreactor.com/user-guide/create-cluster#possible-cluster-topologies).

It’s possible to define a [“bridge”](http://www.steves-internet-guide.com/mosquitto-bridge-configuration/) between Mosquitto brokers so that they can share messages. In this case, we just want a one way stream between all users and a central Mosquitto broker. On the central server with the central broker, we can just write those messages to disk (or duplicate what we do in the Pioreactor, and write to tables in SQLite3).

The central server needs to be accessible, which suggests a public API (with credentials), but you could also use a project like [Tailscale](https://tailscale.com/) to create a private VPN with users’ leaders.

### Using plugins (more Python, but less networking)

You can write a Python script that

1. listens to all topics in MQTT, and
2. serializes the topic and message and pushes it to an API on some central server.

The server is set up as a webserver and knows how to handle incoming requests (writes to disk, saves to a db, etc).

This script can be distributed to users to run in the background. More formally, the Python script could be a proper Pioreactor plugin if you wanted, too.

---

<div class="post-metadata">

**Author:** ![Martin](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/martin/32/66_2.png) [@Martin](https://forum.pioreactor.com/u/Martin)\
**Post date:** [June 30, 2023, 8:50pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/5 "2023-06-30T20:50:44Z")

</div>

That sounds excellent, I imagine the plugin option would be better long term. Do you have a feel for which would be closer to real-time?

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [June 30, 2023, 9:44pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/6 "2023-06-30T21:44:01Z")

</div>

I agree, the plugin would be easier to debug and modify, too. Both will be sub-second latency, I imagine. Probably the MQTT approach would be faster, but I don’t think users would notice.

---

<div class="post-metadata">

**Author:** ![Martin](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/martin/32/66_2.png) [@Martin](https://forum.pioreactor.com/u/Martin)\
**Post date:** [July 7, 2023, 12:15am UTC](https://forum.pioreactor.com/t/project-cloud-database/135/7 "2023-07-07T00:15:10Z")

</div>

And do you think we’d be best sticking with SQLite for the cloud database? I normally use GCP (mainly for their carbon credentials) but their Cloud SQL doesn’t include SQLite & not many hosts appear to support it to the same extent that they support PostgreSQL, MySQL & various No SQL options. Conversely one benefit of sticking with SQLite in the cloud would be easier repurposing of Pioreactor code for visualisation of the online data, etc.

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [July 7, 2023, 12:38am UTC](https://forum.pioreactor.com/t/project-cloud-database/135/8 "2023-07-07T00:38:53Z")

</div>

I would use whatever DB you’re most comfortable with. I like SQLite because it works well on Raspberry Pis, but if you are going to use GCP - by all means, use what you like!

I imagine you’d have to design your own schema, too, and perhaps loosely based on some of Pioreactor’s tables (schema’s [here](https://github.com/Pioreactor/CustoPiZer/blob/pioreactor/workspace/scripts/files/sql/create_tables.sql) btw). The Pioreactor UI’s viz’s are just [queries](https://github.com/Pioreactor/pioreactorui/blob/master/views.py#L186-L323) against the tables, and these queries can be adapted to other databases with ease.

---

<div class="post-metadata">

**Author:** ![noahsprent](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/noahsprent/32/383_2.png) [@noahsprent](https://forum.pioreactor.com/u/noahsprent)\
**Post date:** [November 5, 2025, 1:31pm UTC](https://forum.pioreactor.com/t/project-cloud-database/135/9 "2025-11-05T13:31:39Z")

</div>

Hello! I’m tackling this at the moment. Just wanted to check if you’ve had any thoughts since the original thread that would make you consider a different approach? My current thoughts are:

- Pioreactor plugin to serialise MQTT and POST to HTTPS endpoint (some kind of auth)
- Cloud run server with public HTTPS endpoint which parses, batches and updates postgres cloud SQL database over Serverless VPC Access
- Postgres DB that has schema as close to SQLite one as possible - imagine there could be pitfalls here especially with maintaining compatability of the Postgres and SQLite schema if the SQLite schema is updated. Any way to keep these in sync?

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [November 6, 2025, 1:55am UTC](https://forum.pioreactor.com/t/project-cloud-database/135/10 "2025-11-06T01:55:42Z")

</div>

Are you committed to using postgres? If you can get away with sqlite3 on the remote server, there exists a few tools that live-replicate sqlite dbs from one location to another (streaming, essentially). Probably they do schema updates, too.

---

<div class="post-metadata">

**Author:** ![noahsprent](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/noahsprent/32/383_2.png) [@noahsprent](https://forum.pioreactor.com/u/noahsprent)\
**Post date:** [November 7, 2025, 11:55am UTC](https://forum.pioreactor.com/t/project-cloud-database/135/11 "2025-11-07T11:55:25Z")

</div>

Hmm I think we’re pro either postgres or mysql because we can put them on cloud sql from google cloud. And they link in a slightly more straightforward manner to other tools I think. I will keep thinking, thanks!
