python-files-db
Advanced tools
+6
-7
| Metadata-Version: 2.4 | ||
| Name: python-files-db | ||
| Version: 0.0.1a2 | ||
| Version: 0.0.1a3 | ||
| Summary: Lightweight file-system database for Python projects. | ||
@@ -32,3 +32,3 @@ License-File: LICENSE | ||
| - Simple API — quick to start | ||
| - Supports basic CRUD operations: Create, Read, (Update, Delete - now don't realized) | ||
| - Supports basic CRUD operations: Create, Read, Update, Delete | ||
| - Minimal external dependencies | ||
@@ -47,3 +47,2 @@ - Designed for easy integration and flexibility | ||
| from pyfiles_db import FilesDB | ||
| from pathlib | ||
@@ -78,11 +77,11 @@ file_db = FilesDB() | ||
| user_id_1 = db.find("usesr", "id == 1") | ||
| # return [{"id": 1, "name": "Anton", "age": 17}] | ||
| # return [{"1": {"id": 1, "name": "Anton", "age": 17}}] | ||
| user_id_2 = db.find("usesr", "id == 2") | ||
| # return [{"id": 2, "name": "Alex", "age": 17}] | ||
| # return [{"2": {"id": 2, "name": "Alex", "age": 17}}] | ||
| users_age_17 = db.find("users", "age == 17") | ||
| # return [ | ||
| # {"id": 1, "name": "Anton", "age": 17}, | ||
| # {"id": 2, "name": "Alex", "age": 17}, | ||
| # {"1": {"id": 1, "name": "Anton", "age": 17}}, | ||
| # {"2": {"id": 2, "name": "Alex", "age": 17}, | ||
| # ] | ||
@@ -89,0 +88,0 @@ |
+1
-1
| [project] | ||
| name = "python-files-db" | ||
| version = "0.0.1-alpha.2" | ||
| version = "0.0.1-alpha.3" | ||
| description = "Lightweight file-system database for Python projects." | ||
@@ -5,0 +5,0 @@ authors = [ |
+5
-6
@@ -14,3 +14,3 @@ # pyfiles_db | ||
| - Simple API — quick to start | ||
| - Supports basic CRUD operations: Create, Read, (Update, Delete - now don't realized) | ||
| - Supports basic CRUD operations: Create, Read, Update, Delete | ||
| - Minimal external dependencies | ||
@@ -29,3 +29,2 @@ - Designed for easy integration and flexibility | ||
| from pyfiles_db import FilesDB | ||
| from pathlib | ||
@@ -60,11 +59,11 @@ file_db = FilesDB() | ||
| user_id_1 = db.find("usesr", "id == 1") | ||
| # return [{"id": 1, "name": "Anton", "age": 17}] | ||
| # return [{"1": {"id": 1, "name": "Anton", "age": 17}}] | ||
| user_id_2 = db.find("usesr", "id == 2") | ||
| # return [{"id": 2, "name": "Alex", "age": 17}] | ||
| # return [{"2": {"id": 2, "name": "Alex", "age": 17}}] | ||
| users_age_17 = db.find("users", "age == 17") | ||
| # return [ | ||
| # {"id": 1, "name": "Anton", "age": 17}, | ||
| # {"id": 2, "name": "Alex", "age": 17}, | ||
| # {"1": {"id": 1, "name": "Anton", "age": 17}}, | ||
| # {"2": {"id": 2, "name": "Alex", "age": 17}, | ||
| # ] | ||
@@ -71,0 +70,0 @@ |
@@ -84,2 +84,34 @@ # Copyright 2025 LangNeuron | ||
| @abstractmethod | ||
| def update(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| new_data: dict[str, Any], | ||
| ) -> None: | ||
| """Update data with file_id. | ||
| Get file_id from find method. | ||
| Parameters | ||
| ---------- | ||
| file_id : str | ||
| unical file name | ||
| new_data : dict[str, Any] | ||
| new data when need save | ||
| """ | ||
| @abstractmethod | ||
| def delete(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| ) -> None: | ||
| """Delete data with file_id. | ||
| Parameters | ||
| ---------- | ||
| table_name : str | ||
| name of table db | ||
| file_id : str | ||
| name of file in table | ||
| """ | ||
| class _AsyncDB(ABC): | ||
@@ -148,1 +180,34 @@ @abstractmethod | ||
| """ | ||
| @abstractmethod | ||
| async def update(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| new_data: dict[str, Any], | ||
| ) -> None: | ||
| """Update data with file_id. | ||
| Get file_id from find method. | ||
| Parameters | ||
| ---------- | ||
| file_id : str | ||
| unical file name | ||
| new_data : dict[str, Any] | ||
| new data when need save | ||
| """ | ||
| @abstractmethod | ||
| async def delete(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| ) -> None: | ||
| """Delete data with file_id. | ||
| Parameters | ||
| ---------- | ||
| table_name : str | ||
| name of table db | ||
| file_id : str | ||
| name of file in table | ||
| """ |
@@ -237,3 +237,3 @@ # Copyright 2025 LangNeuron | ||
| ------- | ||
| dict[str, Any] | ||
| list[dict[str, Any]] | ||
| all data when find condition | ||
@@ -263,3 +263,3 @@ | ||
| if isinstance(data, dict): | ||
| return [data] | ||
| return [{str(value): data}] | ||
| return [] | ||
@@ -278,3 +278,3 @@ async with aiofiles.open( | ||
| if d[column_name] == value and isinstance(d, dict): | ||
| result.append(d) | ||
| result.append({str(name): d}) | ||
| return result | ||
@@ -298,1 +298,41 @@ | ||
| return column_name in self._meta[table_name][META.COLUMNS] | ||
| async def update(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| new_data: dict[str, Any], | ||
| ) -> None: | ||
| """Update data with file_id. | ||
| Get file_id from find method. | ||
| Parameters | ||
| ---------- | ||
| file_id : str | ||
| unical file name | ||
| new_data : dict[str, Any] | ||
| new data when need save | ||
| """ | ||
| table_name = self._meta[META.TABLE_PREFIX] + table_name | ||
| async with aiofiles.open( | ||
| self._storage / table_name / f"{file_id}.json", | ||
| mode="w") as f: | ||
| await f.write(json.dumps(new_data)) | ||
| async def delete(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| ) -> None: | ||
| """Delete data with file_id. | ||
| Parameters | ||
| ---------- | ||
| table_name : str | ||
| name of table db | ||
| file_id : str | ||
| name of file in table | ||
| """ | ||
| table_name = self._meta[META.TABLE_PREFIX] + table_name | ||
| if not (self._storage / table_name / f"{file_id}.json").exists(): | ||
| raise FileNotFoundError | ||
| (self._storage / table_name / f"{file_id}.json").unlink() |
@@ -218,3 +218,3 @@ # Copyright 2025 LangNeuron | ||
| if isinstance(data, dict): | ||
| return [data] | ||
| return [{str(value): data}] | ||
| return [] | ||
@@ -232,3 +232,3 @@ with Path.open( | ||
| if d[column_name] == value and isinstance(d, dict): | ||
| result.append(d) | ||
| result.append({str(name): d}) | ||
| return result | ||
@@ -280,1 +280,42 @@ | ||
| raise UnknownDataTypeError | ||
| def update(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| new_data: dict[str, Any], | ||
| ) -> None: | ||
| """Update data with file_id. | ||
| Get file_id from find method. | ||
| Parameters | ||
| ---------- | ||
| file_id : str | ||
| unical file name | ||
| new_data : dict[str, Any] | ||
| new data when need save | ||
| """ | ||
| table_name = self._meta[META.TABLE_PREFIX] + table_name | ||
| with Path.open( | ||
| self._storage / table_name / f"{file_id}.json", | ||
| mode="w") as f: | ||
| json.dump(new_data, f) | ||
| def delete(self, | ||
| table_name: str, | ||
| file_id: str, | ||
| ) -> None: | ||
| """Delete data with file_id. | ||
| Parameters | ||
| ---------- | ||
| table_name : str | ||
| name of table db | ||
| file_id : str | ||
| name of file in table | ||
| """ | ||
| table_name = self._meta[META.TABLE_PREFIX] + table_name | ||
| if not (self._storage / table_name / f"{file_id}.json").exists(): | ||
| raise FileNotFoundError | ||
| (self._storage / table_name / f"{file_id}.json").unlink() |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
64123
6.52%1293
10.8%