TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Jinbase – Multi-model transactional embedded database

48 pointsby alexrustic6 months ago
Hi HN ! Alex here. I&#x27;m excited to show you Jinbase (<a href="https:&#x2F;&#x2F;github.com&#x2F;pyrustic&#x2F;jinbase">https:&#x2F;&#x2F;github.com&#x2F;pyrustic&#x2F;jinbase</a>), my multi-model transactional embedded database.<p>Almost a year ago, I introduced Paradict [1], my take on multi-format streaming serialization. Given its readability, the Paradict text format appears de facto as an interesting data format for config files. But using Paradict to manage config files would end up cluttering its programming interface and making it confusing for users who still have choices of alternative libraries (TOML, INI File, etc.) dedicated to config files. So I used Paradict as a dependency for KvF (Key-value file format) [2], a new project of mine that focuses on config files with sections.<p>With its compact binary format, I thought Paradict would be an efficient dependency for a new project that would rely on I&#x2F;O functions (such as Open, Read, Write, Seek, Tell and Close) to implement a minimalistic yet reliable persistence solution. But that was before I learned that &quot;files are hard&quot; [3]. SQLite with its transactions, BLOB data type and incremental I&#x2F;O for BLOBs seemed like the right giant to stand on for my new project.<p>Jinbase started small as a key-value store and ended up as a multi-model embedded database that pushes the boundaries of what we usually do with SQLite. The first transition to the second data model (the depot) happened when I realized that the key-value store was not well suited for cases where a unique identifier is supposed to be automatically generated for each new record, saving the user the burden of providing an identifier that could accidentally be subject to a collision and thus overwrite an existing record. After that, I implemented a search capability that accepts UID ranges for the depot store, timespans (records are automatically timestamped) for both the depot and key-value stores and GLOB patterns and number ranges for string and integer keys in the key-value store.<p>The queue and stack data models emerged as solutions for use cases where records must be consumed in a specific order. A typical record would be retrieved and deleted from the database in a single transaction unit.<p>Since SQLite is used as the storage engine, Jinbase supports the relational model de facto. For convenience, all tables related to Jinbase internals are prefixed with &quot;jinbase_&quot;, making Jinbase a useful tool for opening legacy SQLite files to add new data models that will safely coexist with the ad hoc relational model.<p>All four main data models (key-value, depot, queue, stack) support Paradict-compatible data types, such as dictionaries, strings, binary data, integers, datetimes, etc. Under the hood, when the user initiates a write operation, Jinbase serializes (except for binary data), chunks, and stores the data iteratively. A record can be accessed not only in bulk, but also with two levels of partial access granularity: the byte-level and the field-level.<p>While SQLite&#x27;s incremental I&#x2F;O for BLOBs is designed to target an individual BLOB column in a row, Jinbase extends this so that for each record, incremental reads cover all chunks as if they were a single unified BLOB. For dictionary records only, Jinbase automatically creates and maintains a lightweight index consisting of pointers to root fields, which then allows extracting from an arbitrary record the contents of a field automatically deserialized before being returned.<p>The most obvious use cases for Jinbase are storing user preferences, persisting session data before exit, order-based processing of data streams, exposing data for other processes, upgrading legacy SQLite files with new data models and bespoke data persistence solutions.<p>Jinbase is written in Python, is available on PyPI and you can play with the examples on the README.<p>Let me know what you think about this project.<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38684724">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38684724</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;pyrustic&#x2F;kvf">https:&#x2F;&#x2F;github.com&#x2F;pyrustic&#x2F;kvf</a><p>[3] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10725859">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10725859</a>

2 comments

lukevp6 months ago
This is interesting! I understand the reference implementation of the client being in a specific language, since it kind of has to be to be runnable. But I’m a little off put by the selection of a Python-only serialization format as well. So to implement this in another language, both the Jinbase model concepts as well as the serializer&#x2F;deserializer have to be implemented. Wouldn’t it have made more sense to use MessagePack or Protobuf or one of the other formats that already has ubiquitous language support? I understand you are the author of the Paradict format but it seems like a non-starter for wide adoption of Jinbase across languages.
评论 #42290113 未加载
BratakDev6 months ago
How does Jinbase handle concurrency? Since it’s built on SQLite, does it inherit SQLite’s locking mechanisms, or have you implemented additional features to manage concurrent access across the different data models?
评论 #42296357 未加载