Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What would happen in a World without Mongo? #71

Closed
habig opened this issue Sep 29, 2023 · 2 comments
Closed

What would happen in a World without Mongo? #71

habig opened this issue Sep 29, 2023 · 2 comments
Labels
question Further information is requested

Comments

@habig
Copy link

habig commented Sep 29, 2023

Mongo started out life as the data structure in which we stored alerts to form a coincidence. Now we do that in with python data structures.

We log heartbeats to csv.

We log alerts to mongo, but we reset Mongo each day due to our data retention idea of "won't keep it fot more than a day".

What if we also logged alerts to a flat file? We already have the machinery to purge old data from the heartbeats. Could re-use that for alerts too.

Not having Mongo eliminates a lot of complexity: don't have to install that, don't have to include it and its ports in the containers.

@justinvasel
Copy link
Contributor

One option would be to replace Mongo with a simple SQLite database. It has all the greatest hits from your favorite SQL databases without the overhead of running a separate process/server. The DB itself can be stored either in memory, or as a file on disk if persistency following a crash/restart is needed.

An Object-Relational Mapper (ORM) wrapper library makes it easy to abstract out using raw SQL queries. SQLModel (pip3 install sqlmodel) is a great one that links the python data model classes to their corresponding DB table schema (and vice-versa). It also handle things like validation, SQL statement sanitation, ensuring transactions are ACID-compliant, etc under the hood.

SQLModel: https://sqlmodel.tiangolo.com/
Simple example of creating a data class and inserting instances of it into a DB:
image

@justinvasel justinvasel added the question Further information is requested label Sep 29, 2023
@KaraMelih
Copy link
Collaborator

I think no longer applies. sqlalchemy is implemented in #106 closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants