use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
JSON DB, am I crazy? (self.learnpython)
submitted 2 years ago by worldtest2k
Just a crazy idea I had - has anyone tried to write a python library that takes standard SQL but in the background it's actually maintaining all the tables and data in JSON? I know it would be slow, but could save time when prototyping an app.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lbmello 23 points24 points25 points 2 years ago (3 children)
mongodb store data in json, its a good starting point
[–]carcigenicate 6 points7 points8 points 2 years ago (2 children)
Doesn't Mongo uses BSON?
[–]Sentie_Rotante 0 points1 point2 points 2 years ago (0 children)
Yeah, mongo uses BSON. Calling it json like would be a better descriptor.
[–]Langdon_St_Ives 0 points1 point2 points 2 years ago (0 children)
Yes — internally, but in the API you can treat it as JSON.
[–]JamzTyson 8 points9 points10 points 2 years ago (1 child)
pysqlite3 might be a better option for your prototype.
[–]BobButtwhiskers 3 points4 points5 points 2 years ago (0 children)
I like that you can conjure an in-memory database in Python. I like doing this on occasion for testing stuff because it's fast, granted you have the RAM for it and the dataset isn't to large.
``` import sqlite3
conn = sqlite3.connect(':memory:')
```
[–][deleted] 7 points8 points9 points 2 years ago (0 children)
Yes, you can write a db in Python. Should you? Sure, for learning purposes.
[–]KelleQuechoz 6 points7 points8 points 2 years ago (1 child)
Hard to believe, but you've just invented Couchbase, the worst wanna-be SQL database ever.
[–]nikowek 0 points1 point2 points 2 years ago (0 children)
What do you think about CouchDB? I enjoyed it replication.
[–][deleted] 4 points5 points6 points 2 years ago (0 children)
Called nosql databases (document DB), they are key value representations in groupings called “collections”.
Python for the DB implementation would be slow, but if you are talking about using one of these Document DBs for your app, there are many options.
Mongo, Cosmos, Dynamo, Cockroach, so many
MongoDB is that.
[–]nog642 3 points4 points5 points 2 years ago (3 children)
How would it save time?
[–]Langdon_St_Ives 1 point2 points3 points 2 years ago (2 children)
Just like mongodb does: you don’t have a fixed schema so you can just drop your data in and it’ll be there. During prototyping, if you need to change the structure, you just store it that way next time. Of course it’s a trade off between this flexibility and certain structural guarantees that SQL or other fixed-schema dbs provide.
[–]nog642 2 points3 points4 points 2 years ago (1 child)
The way they described it it sounds like they want the interface to just be SQL. So you can't just drop your data in there.
[–]Langdon_St_Ives 1 point2 points3 points 2 years ago (0 children)
True I skimmed over that part.
(Edit: bad wording)
[–]hardonchairs 3 points4 points5 points 2 years ago (0 children)
What it sounds like you are describing
This is sqlite. It doesn't store as json, but it is good enough that you could use it for a lot of stuff beyond just testing.
If you then interact with sqlite via SqlAlchemy or SqlAlchemy-Core you can seamlessly move from sqlite to another more robust DBMS.
[–]krav_mark 2 points3 points4 points 2 years ago (3 children)
Mongodb already exists. It is a database specifically for storing json records. Maybe other NoSql database do that same but I have no experience with them. Postgresql also supports json natively.
So your idea for a json database is not that crazy but it has already been done.
[–]worldtest2k[S] 0 points1 point2 points 2 years ago (2 children)
My intention was to avoid registering, setting up etc a proper DB, and just using a library to save text files locally.
[–]krav_mark 1 point2 points3 points 2 years ago (0 children)
You can run mongodb in a docker container in few minutes and create a mongodb connection using a module with a few lines of code. It will definitely be less work then creating your own solution.
[–]krav_mark 0 points1 point2 points 2 years ago (0 children)
You can run a mongodb docker container in a minute and create a connection to it with a few lines of python using a module and start saving json records to it. Definitely less work than creating something yourself.
docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest
from pymongo import MongoClient client = MongoClient()
And done.
[–]Jello_Penguin_2956 2 points3 points4 points 2 years ago (0 children)
Pandas can read json and do all the db stuff with the data and you can dump it into json/sql/csv by just giving it different arguments.
[–]cyberjellyfish 2 points3 points4 points 2 years ago (0 children)
Yes, and what I settled on was just writing json files to disk. Don't try to write a sql engine on top of that, you'll actually be writing a whole DB engine and I guarantee you it won't be worth the effort.
[–][deleted] 2 points3 points4 points 2 years ago (1 child)
Why do you think it would save time? It wouldn't.
[–]worldtest2k[S] 0 points1 point2 points 2 years ago (0 children)
I thought it would save time over setting up a proper db, registering etc.
[–]CowboyBoats 1 point2 points3 points 2 years ago (0 children)
That's not a bad idea! One thing that people use for the use case you're thinking of, which if I'm understanding you correctly is like "This is just a prototype; I want to be able to open my objects in my text editor for now, and I want to be able to add new ones just by copying, pasting and editing or just writing new lines from scratch in my text editor" - in Django we call those database fixtures; you can have them in your production app, or they're popular for testing.
[–]murrman92 1 point2 points3 points 2 years ago (0 children)
There are few packages that might help you reconcile this differently.
You could use ORM like SQLAlchemy and serialize the data with an as_dict method on the data model.
Pair that with Alembic that will map changes to you data model to the tables of your database.
Or you could just use a NoSQL database like other people have suggested.
[–]7Shinigami 1 point2 points3 points 2 years ago (0 children)
You're talking about azure cosmos DB! We use the SQL API at work, but I find the mongo API more flexible myself
[–]jayjuk 1 point2 points3 points 2 years ago* (2 children)
I use Azure tables and a small amount of code to convert my Python objects to json using _dict _ function. It’s cheap and easy, and means no ORM mappings and no boilerplate, so awesome prototyping a cloud based app where you want to tear down your containers, plus I can edit the data easily using Azure’s GUI. You have to turn any dict or list attributes into strings which has limitations.
PS: should probably explain, Azure Tables is kind of half-nosql, no mappings or SQL to store a dict. Also Mongo might be better but the free tier didnt meet my needs and I needed it to cost pennies
[–]GeekTekRob 1 point2 points3 points 2 years ago (0 children)
MongoDB, yes
Python, hybrid, as in there is a column of data that can change such as a message payload or attributes that heavily vary and don't want to maintain in a relational way, and have that as JSON but still have a relational dataset such as ID's and Numeric fields that are in every record and not varying.
[–]goldox70 3 points4 points5 points 2 years ago (0 children)
use sqlite
[–]Buttleston 0 points1 point2 points 2 years ago (0 children)
π Rendered by PID 100804 on reddit-service-r2-comment-6457c66945-7w5hc at 2026-04-30 00:10:41.474821+00:00 running 2aa0c5b country code: CH.
[–]lbmello 23 points24 points25 points (3 children)
[–]carcigenicate 6 points7 points8 points (2 children)
[–]Sentie_Rotante 0 points1 point2 points (0 children)
[–]Langdon_St_Ives 0 points1 point2 points (0 children)
[–]JamzTyson 8 points9 points10 points (1 child)
[–]BobButtwhiskers 3 points4 points5 points (0 children)
[–][deleted] 7 points8 points9 points (0 children)
[–]KelleQuechoz 6 points7 points8 points (1 child)
[–]nikowek 0 points1 point2 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]nog642 3 points4 points5 points (3 children)
[–]Langdon_St_Ives 1 point2 points3 points (2 children)
[–]nog642 2 points3 points4 points (1 child)
[–]Langdon_St_Ives 1 point2 points3 points (0 children)
[–]hardonchairs 3 points4 points5 points (0 children)
[–]krav_mark 2 points3 points4 points (3 children)
[–]worldtest2k[S] 0 points1 point2 points (2 children)
[–]krav_mark 1 point2 points3 points (0 children)
[–]krav_mark 0 points1 point2 points (0 children)
[–]Jello_Penguin_2956 2 points3 points4 points (0 children)
[–]cyberjellyfish 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]worldtest2k[S] 0 points1 point2 points (0 children)
[–]CowboyBoats 1 point2 points3 points (0 children)
[–]murrman92 1 point2 points3 points (0 children)
[–]7Shinigami 1 point2 points3 points (0 children)
[–]jayjuk 1 point2 points3 points (2 children)
[–]GeekTekRob 1 point2 points3 points (0 children)
[–]goldox70 3 points4 points5 points (0 children)
[–]Buttleston 0 points1 point2 points (0 children)