Replies: 1 comment
-
Basically, tables are represented like this: {
"table_name": {
"document_id": {
"your": "document"
}
}
} The default table's name is Originally (before v2.0), TinyDB used lists to store documents, but that way looking up a document by ID was really slow for large tables. That's where using the document ID as a key comes from. As a last note: In JSON all object keys MUST be strings, so every document ID will be stored as a string regardless of its Python type. That's why TinyDB has to convert the document ID back to its original type when reading data, see for example Lines 249 to 256 in 6307a9f |
Beta Was this translation helpful? Give feedback.
-
I'd like someone to give me a basic explanation of how TinyDB stores data and how it is represented in the JSON it creates. Basically, I'd like to know how it represents a database, a table, a row and an entry inside the JSON
I read the Getting Started and skimmed through the Asvanced usage sections the documentation, but still have doubts,
That because I inserted some entries into a database using
db.insert()
. However, when check the JSON file, I have something like this:As you can see, stuff is nested, and I don't know what is the name of the database (I'm supposing it's
"_default"
, what is a table, what is a row and how exactly it decides to nest the entries.Beta Was this translation helpful? Give feedback.
All reactions