zarr-sqlite 1.0.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zarr_sqlite-1.0.1/PKG-INFO +111 -0
- zarr_sqlite-1.0.1/README.md +93 -0
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/pyproject.toml +7 -1
- zarr_sqlite-1.0.1/src/zarr_sqlite/__init__.py +92 -0
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/src/zarr_sqlite/_db_utils.py +14 -6
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/src/zarr_sqlite/zarr_sqlite.py +34 -19
- zarr_sqlite-1.0.0/PKG-INFO +0 -61
- zarr_sqlite-1.0.0/README.md +0 -46
- zarr_sqlite-1.0.0/src/zarr_sqlite/__init__.py +0 -5
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/LICENSE.txt +0 -0
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/src/zarr_sqlite/_version.py +0 -0
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/src/zarr_sqlite/async_sqlite.py +0 -0
- {zarr_sqlite-1.0.0 → zarr_sqlite-1.0.1}/src/zarr_sqlite/py.typed +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zarr-sqlite
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Single-file Zarr v3 dataset store using SQLite
|
|
5
|
+
Author: Francis Thérien
|
|
6
|
+
Author-email: Francis Thérien <frtherien@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE.txt
|
|
9
|
+
Requires-Dist: zarr>=3.2.1
|
|
10
|
+
Requires-Dist: mypy>=1.17.0 ; extra == 'test'
|
|
11
|
+
Requires-Dist: pytest>=8.4.1 ; extra == 'test'
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Project-URL: Documentation, https://auxym.github.io/zarr-sqlite-python/zarr_sqlite.html
|
|
14
|
+
Project-URL: Format specification, https://github.com/auxym/zarr-sqlite-python/blob/main/SPEC.md
|
|
15
|
+
Project-URL: Source, https://github.com/auxym/zarr-sqlite-python
|
|
16
|
+
Provides-Extra: test
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# zarr-sqlite-python
|
|
20
|
+
|
|
21
|
+
**Store [Zarr](zarr.dev) datasets in a single SQLite database.**
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/project/zarr-sqlite/)
|
|
24
|
+
|
|
25
|
+
`zarr-sqlite` is a Python library which provides `SQLiteStore`, a single-file store implementation
|
|
26
|
+
backed by SQLite for [zarr-python](https://zarr.readthedocs.io/en/stable/). It combines Zarr's chunked, hierarchical data model with SQLite's single-file database format, mutability and ACID guarantees.
|
|
27
|
+
|
|
28
|
+
## Why SQLiteStore?
|
|
29
|
+
|
|
30
|
+
* Single file — complete Zarr hierarchy is stored in one .zarrdb file.
|
|
31
|
+
* ACID transactions — writes are backed by SQLite's transactional database
|
|
32
|
+
engine. A crash or power loss during a write cannot corrupt the entire file,
|
|
33
|
+
at most, a single chunk may be lost. Readers can safely access the store
|
|
34
|
+
concurrently with writers and are guaranteed to see a consistent view of the
|
|
35
|
+
data.
|
|
36
|
+
* Mutable storage — arrays can be modified, overwritten, resized, appended to
|
|
37
|
+
and deleted.
|
|
38
|
+
|
|
39
|
+
`SQLiteStore` is primarily intended for relatively small Zarr datasets (typically
|
|
40
|
+
up to a few gigabytes) where the convenience of a single file is useful for
|
|
41
|
+
archival, distribution, or sharing. It is not intended as an alternative to
|
|
42
|
+
cloud-based object storage designed for chunk-level access to multi-terabyte
|
|
43
|
+
datasets.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Install from PyPI using your favorite package manager, for example:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
pip install zarr-sqlite
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
uv add zarr-sqlite
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import zarr
|
|
61
|
+
|
|
62
|
+
from zarr_sqlite import SQLiteStore
|
|
63
|
+
|
|
64
|
+
with SQLiteStore("my_zarr_file.zarrdb") as store:
|
|
65
|
+
root = zarr.create_group(store=store)
|
|
66
|
+
foo = root.create_group("foo")
|
|
67
|
+
bar = foo.create_group("bar")
|
|
68
|
+
z1 = bar.create_array(name="baz", shape=(10000, 10000), chunks=(1000, 1000), dtype="int32")
|
|
69
|
+
z1[:] = 42
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`SQLiteStore` otherwise behaves identically to other stores used with zarr.
|
|
73
|
+
See the [zarr-python user guide](https://zarr.readthedocs.io/en/stable/user-guide/storage.html)
|
|
74
|
+
for more information.
|
|
75
|
+
|
|
76
|
+
## Documentation
|
|
77
|
+
|
|
78
|
+
There isn't much more to using `SQLiteStore` as it "just works" with
|
|
79
|
+
zarr-python. Full API reference can be accessed by running `uv run pdoc -d
|
|
80
|
+
numpy` (or `just doc` if you have [just](https://just.systems/) installed).
|
|
81
|
+
|
|
82
|
+
A copy of the API documentation for the current *main* branch is also hosted here:
|
|
83
|
+
|
|
84
|
+
**[Documentation for zarr_sqlite](https://auxym.github.io/zarr-sqlite-python)**
|
|
85
|
+
|
|
86
|
+
## How it works
|
|
87
|
+
|
|
88
|
+
`SQLiteStore` implements the [abstract store
|
|
89
|
+
interface](https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#abstract-store-interface)
|
|
90
|
+
defined by the Zarr Core Specification, which essentially provides a key-value
|
|
91
|
+
storage interface. It maps this interface directly onto a SQLite table, using
|
|
92
|
+
string keys and binary BLOB values. Keys correspond to Zarr paths, while values
|
|
93
|
+
contain either array chunks or Zarr metadata items. SQLite then provides the
|
|
94
|
+
persistence and transactional semantics underneath the Zarr store.
|
|
95
|
+
|
|
96
|
+
## Specification
|
|
97
|
+
|
|
98
|
+
The file format is described by a [specification stored in this project's
|
|
99
|
+
repository](./SPEC.md). This document should allow the implementation of
|
|
100
|
+
SQLiteStore for other programming languages or Zarr libraries.
|
|
101
|
+
|
|
102
|
+
## Status
|
|
103
|
+
|
|
104
|
+
The version of this library was incremented to v1.0 to reflect the fact that it
|
|
105
|
+
complies with v1 of the SQLiteStore Specification. However, this is a relatively
|
|
106
|
+
young library that has not seen a lot of real-world use yet, therefore users
|
|
107
|
+
should expect the occasional bug, and possibly breaking API changes in future
|
|
108
|
+
versions, if absolutely necessary.
|
|
109
|
+
|
|
110
|
+
The database format defined by the [Specification](./SPEC.md) is intended to provide
|
|
111
|
+
a stable basis for interoperability between implementations.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# zarr-sqlite-python
|
|
2
|
+
|
|
3
|
+
**Store [Zarr](zarr.dev) datasets in a single SQLite database.**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/zarr-sqlite/)
|
|
6
|
+
|
|
7
|
+
`zarr-sqlite` is a Python library which provides `SQLiteStore`, a single-file store implementation
|
|
8
|
+
backed by SQLite for [zarr-python](https://zarr.readthedocs.io/en/stable/). It combines Zarr's chunked, hierarchical data model with SQLite's single-file database format, mutability and ACID guarantees.
|
|
9
|
+
|
|
10
|
+
## Why SQLiteStore?
|
|
11
|
+
|
|
12
|
+
* Single file — complete Zarr hierarchy is stored in one .zarrdb file.
|
|
13
|
+
* ACID transactions — writes are backed by SQLite's transactional database
|
|
14
|
+
engine. A crash or power loss during a write cannot corrupt the entire file,
|
|
15
|
+
at most, a single chunk may be lost. Readers can safely access the store
|
|
16
|
+
concurrently with writers and are guaranteed to see a consistent view of the
|
|
17
|
+
data.
|
|
18
|
+
* Mutable storage — arrays can be modified, overwritten, resized, appended to
|
|
19
|
+
and deleted.
|
|
20
|
+
|
|
21
|
+
`SQLiteStore` is primarily intended for relatively small Zarr datasets (typically
|
|
22
|
+
up to a few gigabytes) where the convenience of a single file is useful for
|
|
23
|
+
archival, distribution, or sharing. It is not intended as an alternative to
|
|
24
|
+
cloud-based object storage designed for chunk-level access to multi-terabyte
|
|
25
|
+
datasets.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Install from PyPI using your favorite package manager, for example:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
pip install zarr-sqlite
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
uv add zarr-sqlite
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import zarr
|
|
43
|
+
|
|
44
|
+
from zarr_sqlite import SQLiteStore
|
|
45
|
+
|
|
46
|
+
with SQLiteStore("my_zarr_file.zarrdb") as store:
|
|
47
|
+
root = zarr.create_group(store=store)
|
|
48
|
+
foo = root.create_group("foo")
|
|
49
|
+
bar = foo.create_group("bar")
|
|
50
|
+
z1 = bar.create_array(name="baz", shape=(10000, 10000), chunks=(1000, 1000), dtype="int32")
|
|
51
|
+
z1[:] = 42
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`SQLiteStore` otherwise behaves identically to other stores used with zarr.
|
|
55
|
+
See the [zarr-python user guide](https://zarr.readthedocs.io/en/stable/user-guide/storage.html)
|
|
56
|
+
for more information.
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
There isn't much more to using `SQLiteStore` as it "just works" with
|
|
61
|
+
zarr-python. Full API reference can be accessed by running `uv run pdoc -d
|
|
62
|
+
numpy` (or `just doc` if you have [just](https://just.systems/) installed).
|
|
63
|
+
|
|
64
|
+
A copy of the API documentation for the current *main* branch is also hosted here:
|
|
65
|
+
|
|
66
|
+
**[Documentation for zarr_sqlite](https://auxym.github.io/zarr-sqlite-python)**
|
|
67
|
+
|
|
68
|
+
## How it works
|
|
69
|
+
|
|
70
|
+
`SQLiteStore` implements the [abstract store
|
|
71
|
+
interface](https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#abstract-store-interface)
|
|
72
|
+
defined by the Zarr Core Specification, which essentially provides a key-value
|
|
73
|
+
storage interface. It maps this interface directly onto a SQLite table, using
|
|
74
|
+
string keys and binary BLOB values. Keys correspond to Zarr paths, while values
|
|
75
|
+
contain either array chunks or Zarr metadata items. SQLite then provides the
|
|
76
|
+
persistence and transactional semantics underneath the Zarr store.
|
|
77
|
+
|
|
78
|
+
## Specification
|
|
79
|
+
|
|
80
|
+
The file format is described by a [specification stored in this project's
|
|
81
|
+
repository](./SPEC.md). This document should allow the implementation of
|
|
82
|
+
SQLiteStore for other programming languages or Zarr libraries.
|
|
83
|
+
|
|
84
|
+
## Status
|
|
85
|
+
|
|
86
|
+
The version of this library was incremented to v1.0 to reflect the fact that it
|
|
87
|
+
complies with v1 of the SQLiteStore Specification. However, this is a relatively
|
|
88
|
+
young library that has not seen a lot of real-world use yet, therefore users
|
|
89
|
+
should expect the occasional bug, and possibly breaking API changes in future
|
|
90
|
+
versions, if absolutely necessary.
|
|
91
|
+
|
|
92
|
+
The database format defined by the [Specification](./SPEC.md) is intended to provide
|
|
93
|
+
a stable basis for interoperability between implementations.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "zarr-sqlite"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.1"
|
|
4
4
|
description = "Single-file Zarr v3 dataset store using SQLite"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -19,6 +19,11 @@ test = [
|
|
|
19
19
|
"pytest>=8.4.1",
|
|
20
20
|
]
|
|
21
21
|
|
|
22
|
+
[project.urls]
|
|
23
|
+
Documentation = "https://auxym.github.io/zarr-sqlite-python/zarr_sqlite.html"
|
|
24
|
+
Source = "https://github.com/auxym/zarr-sqlite-python"
|
|
25
|
+
"Format specification" = "https://github.com/auxym/zarr-sqlite-python/blob/main/SPEC.md"
|
|
26
|
+
|
|
22
27
|
[build-system]
|
|
23
28
|
requires = ["uv_build>=0.8.3,<0.9.0"]
|
|
24
29
|
build-backend = "uv_build"
|
|
@@ -27,6 +32,7 @@ build-backend = "uv_build"
|
|
|
27
32
|
dev = [
|
|
28
33
|
"mypy==2.3.0",
|
|
29
34
|
"numpy>=2.3.2",
|
|
35
|
+
"pdoc>=16.0.0",
|
|
30
36
|
"pytest>=8.4.1",
|
|
31
37
|
"pytest-asyncio>=1.1.0",
|
|
32
38
|
"pytest-benchmark>=5.2.3",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""
|
|
2
|
+
**zarr-sqlite** is a Python library which provides `SQLiteStore`, a
|
|
3
|
+
single-file store implementation backed by SQLite for
|
|
4
|
+
[zarr-python](https://zarr.readthedocs.io/en/stable/). It combines Zarr's
|
|
5
|
+
chunked, hierarchical data model with SQLite's single-file database format,
|
|
6
|
+
mutability and ACID guarantees.
|
|
7
|
+
|
|
8
|
+
## Why SQLiteStore?
|
|
9
|
+
|
|
10
|
+
* Single file — complete Zarr hierarchy is stored in one .zarrdb file.
|
|
11
|
+
* ACID transactions — writes are backed by SQLite's transactional database
|
|
12
|
+
engine. A crash or power loss during a write cannot corrupt the entire file,
|
|
13
|
+
at most, a single chunk may be lost. Readers can safely access the store
|
|
14
|
+
concurrently with writers and are guaranteed to see a consistent view of the
|
|
15
|
+
data.
|
|
16
|
+
* Mutable storage — arrays can be modified, overwritten, resized, appended to
|
|
17
|
+
and deleted.
|
|
18
|
+
|
|
19
|
+
`SQLiteStore` is primarily intended for relatively small Zarr datasets (typically
|
|
20
|
+
up to a few gigabytes) where the convenience of a single file is useful for
|
|
21
|
+
archival, distribution, or sharing. It is not intended as an alternative to
|
|
22
|
+
cloud-based object storage designed for chunk-level access to multi-terabyte
|
|
23
|
+
datasets.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Install from PyPI using your favorite package manager, for example:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
pip install zarr-sqlite
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
uv add zarr-sqlite
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import zarr
|
|
41
|
+
|
|
42
|
+
from zarr_sqlite import SQLiteStore
|
|
43
|
+
|
|
44
|
+
with SQLiteStore("my_zarr_file.zarrdb") as store:
|
|
45
|
+
root = zarr.create_group(store=store)
|
|
46
|
+
foo = root.create_group("foo")
|
|
47
|
+
bar = foo.create_group("bar")
|
|
48
|
+
z1 = bar.create_array(name="baz", shape=(10000, 10000), chunks=(1000, 1000), dtype="int32")
|
|
49
|
+
z1[:] = 42
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`SQLiteStore` otherwise behaves identically to other stores used with zarr.
|
|
53
|
+
See the [zarr-python user guide](https://zarr.readthedocs.io/en/stable/user-guide/storage.html)
|
|
54
|
+
for more information.
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
`SQLiteStore` implements the [abstract store
|
|
59
|
+
interface](https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#abstract-store-interface)
|
|
60
|
+
defined by the Zarr Core Specification, which essentially provides a key-value
|
|
61
|
+
storage interface. It maps this interface directly onto a SQLite table, using
|
|
62
|
+
string keys and binary BLOB values. Keys correspond to Zarr paths, while values
|
|
63
|
+
contain either array chunks or Zarr metadata items. SQLite then provides the
|
|
64
|
+
persistence and transactional semantics underneath the Zarr store.
|
|
65
|
+
|
|
66
|
+
## Specification
|
|
67
|
+
|
|
68
|
+
The file format is described by a [specification stored in this project's
|
|
69
|
+
repository](./SPEC.md). This document should allow the implementation of
|
|
70
|
+
SQLiteStore for other programming languages or Zarr libraries.
|
|
71
|
+
|
|
72
|
+
## Status
|
|
73
|
+
|
|
74
|
+
The version of this library was incremented to v1.0 to reflect the fact that it
|
|
75
|
+
complies with v1 of the SQLiteStore Specification. However, this is a relatively
|
|
76
|
+
young library that has not seen a lot of real-world use yet, therefore users
|
|
77
|
+
should expect the occasional bug, and possibly breaking API changes in future
|
|
78
|
+
versions, if absolutely necessary.
|
|
79
|
+
|
|
80
|
+
The database format defined by the [Specification](./SPEC.md) is intended to provide
|
|
81
|
+
a stable basis for interoperability between implementations.
|
|
82
|
+
|
|
83
|
+
## API Reference
|
|
84
|
+
|
|
85
|
+
The `SQLiteStore` class implements the [zarr-python `Store` interface](https://zarr.readthedocs.io/en/stable/api/zarr/storage.html#zarr.abc.store.Store).
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
from .zarr_sqlite import SQLiteStore
|
|
89
|
+
|
|
90
|
+
from ._version import __version__
|
|
91
|
+
|
|
92
|
+
__all__ = ["__version__", "SQLiteStore"]
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
def is_in_memory_database(database: str) -> bool:
|
|
2
2
|
"""Check whether a database specifier refers to an in-memory database.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Parameters
|
|
5
|
+
----------
|
|
6
|
+
database : str
|
|
7
|
+
The SQLite database specifier (path, URI, or ":memory:").
|
|
6
8
|
|
|
7
|
-
Returns
|
|
9
|
+
Returns
|
|
10
|
+
-------
|
|
11
|
+
bool
|
|
8
12
|
True if the database is in-memory, False otherwise.
|
|
9
13
|
"""
|
|
10
14
|
return database == ":memory:" or (
|
|
@@ -18,10 +22,14 @@ def is_database_uri(database: str) -> bool:
|
|
|
18
22
|
SQLite URIs use the ``file:`` scheme, e.g. ``file:/path/to/db`` or
|
|
19
23
|
``file::memory:?mode=memory``.
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
database : str
|
|
28
|
+
The SQLite database specifier.
|
|
23
29
|
|
|
24
|
-
Returns
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
bool
|
|
25
33
|
True if the database is a URI, False otherwise.
|
|
26
34
|
"""
|
|
27
35
|
return database.startswith("file:/")
|
|
@@ -50,23 +50,23 @@ def _validate_key(key: str):
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
class SQLiteStore(Store):
|
|
53
|
-
"""
|
|
54
|
-
Store for the local file system.
|
|
53
|
+
"""Single-file SQLite-backed store for Zarr datasets.
|
|
55
54
|
|
|
56
55
|
Parameters
|
|
57
56
|
----------
|
|
58
57
|
database : str or Path
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
Path to the SQLite database file, or ``:memory:`` for an in-memory
|
|
59
|
+
database. The file will be created if it does not already exist.
|
|
60
|
+
read_only : bool, optional
|
|
61
|
+
Whether the store is read-only. In-memory databases cannot be opened
|
|
62
|
+
read-only. Default: False (read-write).
|
|
63
|
+
journal_mode : str, optional
|
|
64
|
+
SQLite journaling mode. ``"WAL"`` (write-ahead log) or ``"DELETE"``
|
|
65
|
+
are supported. If ``None``, the journaling mode will be the database's
|
|
66
|
+
previously set value, or SQLite's default for a new database. Default: WAL.
|
|
67
|
+
page_size : int, optional
|
|
68
|
+
SQLite page size in bytes. The default value of 4096 bytes has been found
|
|
69
|
+
to provide good all-around performance for approximately 1 MB chunks.
|
|
70
70
|
"""
|
|
71
71
|
|
|
72
72
|
_database: str
|
|
@@ -80,16 +80,19 @@ class SQLiteStore(Store):
|
|
|
80
80
|
@property
|
|
81
81
|
@override
|
|
82
82
|
def supports_writes(self) -> bool:
|
|
83
|
+
"""`True`"""
|
|
83
84
|
return True
|
|
84
85
|
|
|
85
86
|
@property
|
|
86
87
|
@override
|
|
87
88
|
def supports_deletes(self) -> bool:
|
|
89
|
+
"""`True`"""
|
|
88
90
|
return True
|
|
89
91
|
|
|
90
92
|
@property
|
|
91
93
|
@override
|
|
92
94
|
def supports_listing(self) -> bool:
|
|
95
|
+
"""`True`"""
|
|
93
96
|
return True
|
|
94
97
|
|
|
95
98
|
def __init__(
|
|
@@ -118,10 +121,12 @@ class SQLiteStore(Store):
|
|
|
118
121
|
self._database = self._database_as_uri(self.database, read_only)
|
|
119
122
|
|
|
120
123
|
@property
|
|
121
|
-
def database(self):
|
|
124
|
+
def database(self) -> str:
|
|
125
|
+
"""The database path or URI as a string."""
|
|
122
126
|
return self._database
|
|
123
127
|
|
|
124
128
|
def is_in_memory(self) -> bool:
|
|
129
|
+
"""Return whether the database is in-memory."""
|
|
125
130
|
return is_in_memory_database(self._database)
|
|
126
131
|
|
|
127
132
|
@staticmethod
|
|
@@ -131,9 +136,9 @@ class SQLiteStore(Store):
|
|
|
131
136
|
Parameters
|
|
132
137
|
----------
|
|
133
138
|
database : str
|
|
134
|
-
File path or
|
|
139
|
+
File path or sqlite-compatible URI (must have `file:` scheme). If
|
|
135
140
|
`database` is a URI, the parameters will be kept unmodified, except
|
|
136
|
-
"mode", which will always be overwritten or added
|
|
141
|
+
"mode", which will always be overwritten or added based on the value
|
|
137
142
|
of `read_only`.
|
|
138
143
|
read_only : bool
|
|
139
144
|
Whether the store is read-only
|
|
@@ -372,8 +377,8 @@ class SQLiteStore(Store):
|
|
|
372
377
|
clause like "(...) WHERE k < :lower_bound AND k > :upper_bound".
|
|
373
378
|
|
|
374
379
|
The upper bound string is obtained by replacing the trailing slash (/)
|
|
375
|
-
character in a prefix with a zero (0)
|
|
376
|
-
character
|
|
380
|
+
character in a prefix with a zero (0) character, which is the next
|
|
381
|
+
character in lexicographical order (in ASCII and Unicode).
|
|
377
382
|
|
|
378
383
|
We do not use GLOB or LIKE in prefix searches because they have many
|
|
379
384
|
issues in SQLite. For example, LIKE does not support case-sensitive
|
|
@@ -423,7 +428,6 @@ class SQLiteStore(Store):
|
|
|
423
428
|
|
|
424
429
|
@override
|
|
425
430
|
def __eq__(self, other: object) -> bool:
|
|
426
|
-
"""Equality comparison."""
|
|
427
431
|
if not isinstance(other, type(self)):
|
|
428
432
|
return False
|
|
429
433
|
|
|
@@ -489,6 +493,17 @@ class SQLiteStore(Store):
|
|
|
489
493
|
|
|
490
494
|
@override
|
|
491
495
|
async def set(self, key: str, value: Buffer) -> None:
|
|
496
|
+
"""Store a (key, value) pair.
|
|
497
|
+
|
|
498
|
+
If the key already exists, its value is replaced.
|
|
499
|
+
|
|
500
|
+
Parameters
|
|
501
|
+
----------
|
|
502
|
+
key : str
|
|
503
|
+
The key to store under.
|
|
504
|
+
value : Buffer
|
|
505
|
+
The value to store.
|
|
506
|
+
"""
|
|
492
507
|
self._check_writable()
|
|
493
508
|
_validate_key(key)
|
|
494
509
|
await self._ensure_open()
|
zarr_sqlite-1.0.0/PKG-INFO
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: zarr-sqlite
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Single-file Zarr v3 dataset store using SQLite
|
|
5
|
-
Author: Francis Thérien
|
|
6
|
-
Author-email: Francis Thérien <frtherien@gmail.com>
|
|
7
|
-
License-Expression: MIT
|
|
8
|
-
License-File: LICENSE.txt
|
|
9
|
-
Requires-Dist: zarr>=3.2.1
|
|
10
|
-
Requires-Dist: mypy>=1.17.0 ; extra == 'test'
|
|
11
|
-
Requires-Dist: pytest>=8.4.1 ; extra == 'test'
|
|
12
|
-
Requires-Python: >=3.12
|
|
13
|
-
Provides-Extra: test
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
|
|
16
|
-
# zarr-sqlite-python
|
|
17
|
-
|
|
18
|
-
SQLite-based single-file store for [zarr](https://zarr.dev/) v3 datasets, in Python.
|
|
19
|
-
|
|
20
|
-
SQLiteStore provides a single-file storage backend for Zarr. Key advantages over alternative single-file formats (e.g., ZipStore):
|
|
21
|
-
|
|
22
|
-
- Support for key deletion, overwriting, and partial value writes.
|
|
23
|
-
- Full ACID guarantees provided by SQLite.
|
|
24
|
-
- High availability of SQLite implementations across programming languages
|
|
25
|
-
and environments.
|
|
26
|
-
|
|
27
|
-
Example usage:
|
|
28
|
-
|
|
29
|
-
```python
|
|
30
|
-
import zarr
|
|
31
|
-
|
|
32
|
-
from zarr_sqlite import SQLiteStore
|
|
33
|
-
|
|
34
|
-
with SQLiteStore("my_zarr_file.zarrdb") as store:
|
|
35
|
-
root = zarr.create_group(store=store)
|
|
36
|
-
foo = root.create_group('foo')
|
|
37
|
-
bar = foo.create_group('bar')
|
|
38
|
-
z1 = bar.create_array(name='baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='int32')
|
|
39
|
-
z1[:] = 42
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
`SQLiteStore` otherwise behaves identically to other stores used with zarr, see
|
|
43
|
-
the [zarr user guide](https://zarr.readthedocs.io/en/stable/user-guide/storage.html)
|
|
44
|
-
for more information.
|
|
45
|
-
|
|
46
|
-
## Specification
|
|
47
|
-
|
|
48
|
-
The store format is described in the document [SPEC.md](/SPEC.md). This document
|
|
49
|
-
should allow the implementation of SQLiteStore for other programming languages
|
|
50
|
-
or Zarr libraries.
|
|
51
|
-
|
|
52
|
-
## Status
|
|
53
|
-
|
|
54
|
-
The version of this library was incremented to v1.0 to reflect the fact that it
|
|
55
|
-
complies with v1 of the SQLiteStore Specification. However, this is a relatively
|
|
56
|
-
new library that has not seen a lot of real-world use yet, therefore users should
|
|
57
|
-
expect the occasional bug, and possibly breaking API changes in future versions,
|
|
58
|
-
if absolutely necessary.
|
|
59
|
-
|
|
60
|
-
The database format however, defined by the Specification, can be expected to be
|
|
61
|
-
stable.
|
zarr_sqlite-1.0.0/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# zarr-sqlite-python
|
|
2
|
-
|
|
3
|
-
SQLite-based single-file store for [zarr](https://zarr.dev/) v3 datasets, in Python.
|
|
4
|
-
|
|
5
|
-
SQLiteStore provides a single-file storage backend for Zarr. Key advantages over alternative single-file formats (e.g., ZipStore):
|
|
6
|
-
|
|
7
|
-
- Support for key deletion, overwriting, and partial value writes.
|
|
8
|
-
- Full ACID guarantees provided by SQLite.
|
|
9
|
-
- High availability of SQLite implementations across programming languages
|
|
10
|
-
and environments.
|
|
11
|
-
|
|
12
|
-
Example usage:
|
|
13
|
-
|
|
14
|
-
```python
|
|
15
|
-
import zarr
|
|
16
|
-
|
|
17
|
-
from zarr_sqlite import SQLiteStore
|
|
18
|
-
|
|
19
|
-
with SQLiteStore("my_zarr_file.zarrdb") as store:
|
|
20
|
-
root = zarr.create_group(store=store)
|
|
21
|
-
foo = root.create_group('foo')
|
|
22
|
-
bar = foo.create_group('bar')
|
|
23
|
-
z1 = bar.create_array(name='baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='int32')
|
|
24
|
-
z1[:] = 42
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
`SQLiteStore` otherwise behaves identically to other stores used with zarr, see
|
|
28
|
-
the [zarr user guide](https://zarr.readthedocs.io/en/stable/user-guide/storage.html)
|
|
29
|
-
for more information.
|
|
30
|
-
|
|
31
|
-
## Specification
|
|
32
|
-
|
|
33
|
-
The store format is described in the document [SPEC.md](/SPEC.md). This document
|
|
34
|
-
should allow the implementation of SQLiteStore for other programming languages
|
|
35
|
-
or Zarr libraries.
|
|
36
|
-
|
|
37
|
-
## Status
|
|
38
|
-
|
|
39
|
-
The version of this library was incremented to v1.0 to reflect the fact that it
|
|
40
|
-
complies with v1 of the SQLiteStore Specification. However, this is a relatively
|
|
41
|
-
new library that has not seen a lot of real-world use yet, therefore users should
|
|
42
|
-
expect the occasional bug, and possibly breaking API changes in future versions,
|
|
43
|
-
if absolutely necessary.
|
|
44
|
-
|
|
45
|
-
The database format however, defined by the Specification, can be expected to be
|
|
46
|
-
stable.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|