ezcosmos 0.1.0__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.
ezcosmos-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rhcproc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: ezcosmos
3
+ Version: 0.1.0
4
+ Summary: A small convenience wrapper for Azure Cosmos DB CRUD operations.
5
+ Author: rhcproc
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rhcproc/ezcosmos
8
+ Project-URL: Repository, https://github.com/rhcproc/ezcosmos
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: azure-cosmos>=4.7.0
21
+ Dynamic: license-file
22
+
23
+ # ezcosmos
24
+
25
+ A small convenience wrapper for Azure Cosmos DB CRUD operations.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install ezcosmos
31
+ ```
32
+
33
+ For local development from this repository:
34
+
35
+ ```bash
36
+ python -m pip install -e .
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Set your Cosmos DB credentials:
42
+
43
+ ```bash
44
+ export COSMOS_URL="https://your-account.documents.azure.com:443/"
45
+ export COSMOS_KEY="your-cosmos-key"
46
+ ```
47
+
48
+ Use the package:
49
+
50
+ ```python
51
+ from ezcosmos import CosmosStore
52
+
53
+ store = CosmosStore(
54
+ database_name="prototype-db",
55
+ container_name="documents",
56
+ partition_key_path="/partitionKey",
57
+ )
58
+
59
+ item = store.write(
60
+ {
61
+ "id": "1",
62
+ "partitionKey": "default",
63
+ "name": "Junbum",
64
+ "city": "Christchurch",
65
+ }
66
+ )
67
+
68
+ print(item)
69
+ ```
70
+
71
+ ## Command Line
72
+
73
+ After installing the package, use the `ezcosmos` command:
74
+
75
+ ```bash
76
+ ezcosmos \
77
+ --database prototype-db \
78
+ --container documents \
79
+ read 1
80
+ ```
81
+
82
+ You can also pass credentials directly instead of using `COSMOS_URL` and
83
+ `COSMOS_KEY`:
84
+
85
+ ```bash
86
+ ezcosmos \
87
+ --url "https://your-account.documents.azure.com:443/" \
88
+ --key "your-cosmos-key" \
89
+ --database prototype-db \
90
+ --container documents \
91
+ write '{"id": "1", "partitionKey": "default", "name": "Junbum"}'
92
+ ```
93
+
94
+ You can also run the sample in `examples/basic_usage.py`:
95
+
96
+ ```bash
97
+ python examples/basic_usage.py
98
+ ```
99
+
100
+ ## Build
101
+
102
+ Install build tooling:
103
+
104
+ ```bash
105
+ python -m pip install build twine
106
+ ```
107
+
108
+ Build the package:
109
+
110
+ ```bash
111
+ python -m build
112
+ ```
113
+
114
+ Check the package metadata:
115
+
116
+ ```bash
117
+ python -m twine check dist/*
118
+ ```
119
+
120
+ Upload to TestPyPI:
121
+
122
+ ```bash
123
+ python -m twine upload --repository testpypi dist/*
124
+ ```
125
+
126
+ Upload to PyPI:
127
+
128
+ ```bash
129
+ python -m twine upload dist/*
130
+ ```
@@ -0,0 +1,108 @@
1
+ # ezcosmos
2
+
3
+ A small convenience wrapper for Azure Cosmos DB CRUD operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ezcosmos
9
+ ```
10
+
11
+ For local development from this repository:
12
+
13
+ ```bash
14
+ python -m pip install -e .
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Set your Cosmos DB credentials:
20
+
21
+ ```bash
22
+ export COSMOS_URL="https://your-account.documents.azure.com:443/"
23
+ export COSMOS_KEY="your-cosmos-key"
24
+ ```
25
+
26
+ Use the package:
27
+
28
+ ```python
29
+ from ezcosmos import CosmosStore
30
+
31
+ store = CosmosStore(
32
+ database_name="prototype-db",
33
+ container_name="documents",
34
+ partition_key_path="/partitionKey",
35
+ )
36
+
37
+ item = store.write(
38
+ {
39
+ "id": "1",
40
+ "partitionKey": "default",
41
+ "name": "Junbum",
42
+ "city": "Christchurch",
43
+ }
44
+ )
45
+
46
+ print(item)
47
+ ```
48
+
49
+ ## Command Line
50
+
51
+ After installing the package, use the `ezcosmos` command:
52
+
53
+ ```bash
54
+ ezcosmos \
55
+ --database prototype-db \
56
+ --container documents \
57
+ read 1
58
+ ```
59
+
60
+ You can also pass credentials directly instead of using `COSMOS_URL` and
61
+ `COSMOS_KEY`:
62
+
63
+ ```bash
64
+ ezcosmos \
65
+ --url "https://your-account.documents.azure.com:443/" \
66
+ --key "your-cosmos-key" \
67
+ --database prototype-db \
68
+ --container documents \
69
+ write '{"id": "1", "partitionKey": "default", "name": "Junbum"}'
70
+ ```
71
+
72
+ You can also run the sample in `examples/basic_usage.py`:
73
+
74
+ ```bash
75
+ python examples/basic_usage.py
76
+ ```
77
+
78
+ ## Build
79
+
80
+ Install build tooling:
81
+
82
+ ```bash
83
+ python -m pip install build twine
84
+ ```
85
+
86
+ Build the package:
87
+
88
+ ```bash
89
+ python -m build
90
+ ```
91
+
92
+ Check the package metadata:
93
+
94
+ ```bash
95
+ python -m twine check dist/*
96
+ ```
97
+
98
+ Upload to TestPyPI:
99
+
100
+ ```bash
101
+ python -m twine upload --repository testpypi dist/*
102
+ ```
103
+
104
+ Upload to PyPI:
105
+
106
+ ```bash
107
+ python -m twine upload dist/*
108
+ ```
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ezcosmos"
7
+ version = "0.1.0"
8
+ description = "A small convenience wrapper for Azure Cosmos DB CRUD operations."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "rhcproc" }
15
+ ]
16
+ dependencies = [
17
+ "azure-cosmos>=4.7.0"
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Developers",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/rhcproc/ezcosmos"
32
+ Repository = "https://github.com/rhcproc/ezcosmos"
33
+
34
+ [project.scripts]
35
+ ezcosmos = "ezcosmos.cli:main"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from importlib.metadata import version
2
+
3
+ from .store import CosmosStore
4
+
5
+ __version__ = version("ezcosmos")
6
+
7
+ __all__ = ["CosmosStore", "__version__"]
@@ -0,0 +1,5 @@
1
+ from . import __version__
2
+
3
+
4
+ def main() -> None:
5
+ print(f"ezcosmos {__version__}")
@@ -0,0 +1,67 @@
1
+ import os
2
+
3
+ from azure.cosmos import CosmosClient, PartitionKey
4
+
5
+
6
+ class CosmosStore:
7
+ def __init__(
8
+ self,
9
+ url=None,
10
+ key=None,
11
+ database_name=None,
12
+ container_name=None,
13
+ partition_key_path="/partitionKey",
14
+ ):
15
+ url = url or os.getenv("COSMOS_URL")
16
+ key = key or os.getenv("COSMOS_KEY")
17
+
18
+ if not url or not key:
19
+ raise ValueError("Missing COSMOS_URL or COSMOS_KEY in environment")
20
+ if not database_name:
21
+ raise ValueError("Missing database_name")
22
+ if not container_name:
23
+ raise ValueError("Missing container_name")
24
+ if not partition_key_path:
25
+ raise ValueError("Missing partition_key_path")
26
+
27
+ self.client = CosmosClient(url, credential=key)
28
+ self.database = self.client.create_database_if_not_exists(
29
+ database_name
30
+ )
31
+ self.container = self.database.create_container_if_not_exists(
32
+ id=container_name,
33
+ partition_key=PartitionKey(path=partition_key_path),
34
+ )
35
+
36
+ def write(self, item):
37
+ return self._clean(self.container.upsert_item(item))
38
+
39
+ def read(self, item_id, partition_key="default"):
40
+ item = self.container.read_item(
41
+ item=item_id,
42
+ partition_key=partition_key,
43
+ )
44
+ return self._clean(item)
45
+
46
+ def delete(self, item_id, partition_key="default"):
47
+ self.container.delete_item(item=item_id, partition_key=partition_key)
48
+
49
+ def update(self, item_id, updates, partition_key="default"):
50
+ item = self.container.read_item(
51
+ item=item_id,
52
+ partition_key=partition_key,
53
+ )
54
+ item.update(updates)
55
+ return self._clean(self.container.upsert_item(item))
56
+
57
+ def query(self, query, parameters=None):
58
+ items = self.container.query_items(
59
+ query=query,
60
+ parameters=parameters or [],
61
+ enable_cross_partition_query=True,
62
+ )
63
+ return [self._clean(item) for item in items]
64
+
65
+ @staticmethod
66
+ def _clean(item):
67
+ return {k: v for k, v in item.items() if not k.startswith("_")}
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: ezcosmos
3
+ Version: 0.1.0
4
+ Summary: A small convenience wrapper for Azure Cosmos DB CRUD operations.
5
+ Author: rhcproc
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rhcproc/ezcosmos
8
+ Project-URL: Repository, https://github.com/rhcproc/ezcosmos
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: azure-cosmos>=4.7.0
21
+ Dynamic: license-file
22
+
23
+ # ezcosmos
24
+
25
+ A small convenience wrapper for Azure Cosmos DB CRUD operations.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install ezcosmos
31
+ ```
32
+
33
+ For local development from this repository:
34
+
35
+ ```bash
36
+ python -m pip install -e .
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ Set your Cosmos DB credentials:
42
+
43
+ ```bash
44
+ export COSMOS_URL="https://your-account.documents.azure.com:443/"
45
+ export COSMOS_KEY="your-cosmos-key"
46
+ ```
47
+
48
+ Use the package:
49
+
50
+ ```python
51
+ from ezcosmos import CosmosStore
52
+
53
+ store = CosmosStore(
54
+ database_name="prototype-db",
55
+ container_name="documents",
56
+ partition_key_path="/partitionKey",
57
+ )
58
+
59
+ item = store.write(
60
+ {
61
+ "id": "1",
62
+ "partitionKey": "default",
63
+ "name": "Junbum",
64
+ "city": "Christchurch",
65
+ }
66
+ )
67
+
68
+ print(item)
69
+ ```
70
+
71
+ ## Command Line
72
+
73
+ After installing the package, use the `ezcosmos` command:
74
+
75
+ ```bash
76
+ ezcosmos \
77
+ --database prototype-db \
78
+ --container documents \
79
+ read 1
80
+ ```
81
+
82
+ You can also pass credentials directly instead of using `COSMOS_URL` and
83
+ `COSMOS_KEY`:
84
+
85
+ ```bash
86
+ ezcosmos \
87
+ --url "https://your-account.documents.azure.com:443/" \
88
+ --key "your-cosmos-key" \
89
+ --database prototype-db \
90
+ --container documents \
91
+ write '{"id": "1", "partitionKey": "default", "name": "Junbum"}'
92
+ ```
93
+
94
+ You can also run the sample in `examples/basic_usage.py`:
95
+
96
+ ```bash
97
+ python examples/basic_usage.py
98
+ ```
99
+
100
+ ## Build
101
+
102
+ Install build tooling:
103
+
104
+ ```bash
105
+ python -m pip install build twine
106
+ ```
107
+
108
+ Build the package:
109
+
110
+ ```bash
111
+ python -m build
112
+ ```
113
+
114
+ Check the package metadata:
115
+
116
+ ```bash
117
+ python -m twine check dist/*
118
+ ```
119
+
120
+ Upload to TestPyPI:
121
+
122
+ ```bash
123
+ python -m twine upload --repository testpypi dist/*
124
+ ```
125
+
126
+ Upload to PyPI:
127
+
128
+ ```bash
129
+ python -m twine upload dist/*
130
+ ```
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/ezcosmos/__init__.py
5
+ src/ezcosmos/cli.py
6
+ src/ezcosmos/store.py
7
+ src/ezcosmos.egg-info/PKG-INFO
8
+ src/ezcosmos.egg-info/SOURCES.txt
9
+ src/ezcosmos.egg-info/dependency_links.txt
10
+ src/ezcosmos.egg-info/entry_points.txt
11
+ src/ezcosmos.egg-info/requires.txt
12
+ src/ezcosmos.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ezcosmos = ezcosmos.cli:main
@@ -0,0 +1 @@
1
+ azure-cosmos>=4.7.0
@@ -0,0 +1 @@
1
+ ezcosmos