davidlatwe / montydb

Monty, Mongo tinified. MongoDB implemented in Python !

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use `montydb` with an existing SQLite database?

Andrew-S-Rosen opened this issue · comments

I have an existing SQLite database on disk (dispatcher_db.sqlite) and was hoping that I could use montydb to make it possible for me to interact with it in Python as if it were a Mongo database.

It wasn't clear from the README how one might (or might not!) be able to do this. Would you mind providing some insight? Thank you!!

Hi @arosen93 👋🏼
This is interesting. But I'm afraid that's not gonna work. 😢

Because montydb uses a SQLite database as a key-value database, here's the command for table creation (or see here):

CREATE TABLE [{}](
    k text NOT NULL,
    v text NOT NULL,
    PRIMARY KEY(k)
);

As you can see, it only has two columns, and if I remember correctly, the value it stores is BSON encoded binary blob. So unless your existing database happens to store data in the same manner, it won't work.

Would be great to have this supported though, might does the trick with a thin mapping/schema layer that wraps around the existing database... Anyway, I am not working on this project for quite a while, cannot say for sure when this will happen, but pull-request is always welcome. 😊

Thank you so much for the reply! Mainly, this is helpful just to know that I can stop trying to see what I'm doing wrong :) I unfortunately don't know enough about SQLite to help with a PR (hence why I was trying montydb to make it more Mongo-like!), but maybe someone will feel inclined to give it a go. Thanks again!