Trên GitHub, coleifer/unqlite-python đã đạt 404 sao, nhóm Data, ngôn ngữ C. Python bindings for the UnQLite embedded NoSQL database
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Fast Python bindings for UnQLite, a lightweight, embedded NoSQL database and JSON document store.
Please note
Read the issue tracker for this database
before considering using it. UnQLite has not seen any meaningful development
since 2014. It is strongly recommended that you use Sqlite.
Sqlite has robust support for json and is
actively developed and maintained.
Features
UnQLite features:
Embedded, zero-conf database
Transactional (ACID)
Single file or in-memory database
Key/value store
Cursor support and linear record traversal
JSON document store
Thread-safe
Terabyte-sized databases
UnQLite-Python features:
Compiled library, extremely fast with minimal overhead.
Supports key/value operations, cursors, and transactions using Pythonic APIs.
Support for Jx9 scripting.
APIs for working with Jx9 JSON document collections.
Links:
unqlite-python documentation
UnQLite's C API
Installation
You can install unqlite using pip.
pip install unqlite
Basic usage
Below is a sample interactive console session designed to show some of the basic features and functionality of the unqlite-python library. Also check out the full API documentation.
To begin, instantiate an UnQLite object. You can specify either the path to a database file, or use UnQLite as an in-memory database.
>>> from unqlite import UnQLite
>>> db = UnQLite() # Create an in-memory database.
Key/value features
UnQLite can be used as a key/value store.
>>> db['foo'] = 'bar' # Use as a key/value store.
>>> db['foo'] # The key/value store deals in byte-strings.
b'bar'
>>> for i in range(4):
... db['k%s' % i] = str(i)
...
>>> 'k3' in db
True
>>> 'k4' in db
False
>>> del db['k3']
>>> db.append('k2', 'XXXX')
>>> db['k2']
b'2XXXX'
>>> db.get('k2') # Like dict.get() -- returns None if not found.
b'2XXXX'
>>> db.get('missing', 'n/a')
'n/a'
>>> list(db.match_prefix('k')) # Iterate keys matching a prefix (O(n) scan).
[('k0', b'0'), ('k1', b'1'), ('k2', b'2XXXX')]
The database can also be iterated through directly. Note that keys are decoded
while values are left as bytestrings.
>>> [item for item in db]
[('foo', b'bar'), ('k0', b'0'), ('k1', b'1'), ('k2', b'2XXXX')]
Cursors
For finer-grained record traversal, you can use cursors.
>>> with db.cursor() as cursor:
... cursor.seek('k0')
... for key, value in cursor:
... print(key, '=>', value.decode('utf8'))
...
k0 => 0
k1 => 1
k2 => 2XXXX
>>> with db.cursor() as cursor:
... cursor.seek('k2')
... print(cursor.value())
...
b'2XXXX'
>>> with db.cursor() as cursor:
... cursor.seek('k0')
... print(list(cursor.fetch_until('k2', include_stop_key=False)))
...
[('k0', b'0'), ('k1', b'1')]
There are many different ways of interacting with cursors, which are described in the Cursor API documentation.
Document store features
In my opinion the most interesting feature of UnQLite is its JSON document store. The Jx9 scripting language is used to interact with the document store, and it is a wacky mix of PHP and maybe JavaScript (?).
Note: as of v0.8.0 the document store and collections APIs treat all
strings as unicode.
Interacting with the document store basically consists of creating a Jx9 script (you might think of it as an imperative SQL query), compiling it, and then executing it.
This is just a taste of what is possible with Jx9. In the near future I may add some wrappers around common Jx9 collection operations, but for now hopefully it is not too difficult to work with.
More information can be found in the VM API documentation.
Collections
To simplify working with JSON document collections, unqlite-python provides a light API for
executing Jx9 queries on collections. A collection is an ordered list of JSON objects
(records). Records can be appended or deleted, and in the next major release of UnQLite there will
be support for updates as well.
To begin working with collections, you can use the factory method on UnQLite:
>>> users = db.collection('users')
>>> users.create() # Create the collection if it does not exist.
>>> users.exists()
True
You can use the store() method to add one or many records. To add a single record just pass in a python dict. To add multiple records, pass in a list of dicts. Records can be fetched and deleted by ID.
By default, the ID of the last-stored record is returned. At the time of
writing, IDs start at 0, so when inserting 3 records the last-id is 2:
>>> users.store([
... {'name': 'Charlie', 'color': 'green'},
... {'name': 'Huey', 'color': 'white'},
... {'name': 'Mickey', 'color': 'black'}])
2
>>> users.store({'name': 'Leslie', 'color': 'also green'}, return_id=False)
True
>>> users.fetch(0) # Fetch the first record.
{'__id': 0, 'color': 'green', 'name': 'Charlie'}
>>> users.delete(0) # Delete the first record.
True
>>> users.delete(users.last_record_id()) # Delete the last record.
True
You can retrieve all records in the collection, or specify a filtering function. The filtering function will be registered as a foreign function with the Jx9 VM and called from the VM.
UnQLite supports transactions for file-backed databases (since transactions occur at the filesystem level, they have no effect on in-memory databases).
The easiest way to create a transaction is with the context manager:
>>> db = UnQLite('/tmp/test.db')
>>> with db.transaction():
... db['k1'] = 'v1'
... db['k2'] = 'v2'
...
>>> db['k1']
b'v1'
You can also use the transaction decorator which will wrap a function call in a transaction and commit upon successful execution (rolling back if an exception occurs).
>>> @db.commit_on_success
... def save_value(key, value, exc=False):
... db[key] = value
... if exc:
... raise Exception('uh-oh')
...
>>> save_value('k3', 'v3')
>>> save_value('k3', 'vx', True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "unqlite/core.py", line 312, in wrapper
return fn(*args, **kwargs)
File "<stdin>", line 5, in save_value
Exception: uh-oh
>>> db['k3']
b'v3'
For finer-grained control you can call db.begin(), db.rollback() and db.commit() manually:
coleifer/unqlite-python có 404 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/coleifer/unqlite-python. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
coleifer/unqlite-python có phải mã nguồn mở không?
Có — coleifer/unqlite-python phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/coleifer/unqlite-python.
coleifer/unqlite-python còn đang phát triển không?
Commit gần nhất trên coleifer/unqlite-python là 12 ngày trước (theo timestamp GitHub). Repo có 34 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
coleifer/unqlite-python dùng license gì?
coleifer/unqlite-python phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
coleifer/unqlite-python là gì?
coleifer/unqlite-python (coleifer/unqlite-python) là dự án C trên GitHub. Theo mô tả gốc: Python bindings for the UnQLite embedded NoSQL database
coleifer/unqlite-python viết bằng ngôn ngữ gì?
coleifer/unqlite-python chủ yếu viết bằng C. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Cùng nhóm Data còn repo nào?
coleifer/unqlite-python thuộc nhóm Data trên TopGit, cùng 4 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về coleifer/unqlite-python ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/coleifer/unqlite-python là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc unqlite-python có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về unqlite-python.