evoid-sqlite 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,107 @@
1
+ """SQLite Storage Engine for EVOID.
2
+
3
+ IOP: Plugin registry pattern — register, resolve, use.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from evoid.engines.plugin import register
13
+
14
+
15
+ # Plugin manifest
16
+ MANIFEST = {
17
+ "name": "evoid-sqlite",
18
+ "version": "0.1.0",
19
+ "type": "engine",
20
+ "description": "SQLite storage engine for EVOID",
21
+ "entry_point": "evoid_sqlite:register_plugin",
22
+ "dependencies": ["aiosqlite>=0.20.0"],
23
+ "evoid_version": ">=0.4.0",
24
+ "tags": ["storage", "sqlite", "database"],
25
+ }
26
+
27
+
28
+ class SQLiteStorage:
29
+ """SQLite storage engine — async, file-based."""
30
+
31
+ def __init__(self, db_path: str = "evoid.db"):
32
+ self.db_path = db_path
33
+ self._conn = None
34
+
35
+ async def connect(self):
36
+ import aiosqlite
37
+ self._conn = await aiosqlite.connect(self.db_path)
38
+ await self._conn.execute("""
39
+ CREATE TABLE IF NOT EXISTS kv_store (
40
+ key TEXT PRIMARY KEY,
41
+ value TEXT NOT NULL,
42
+ namespace TEXT DEFAULT 'default'
43
+ )
44
+ """)
45
+ await self._conn.commit()
46
+
47
+ async def close(self):
48
+ if self._conn:
49
+ await self._conn.close()
50
+
51
+ async def read(self, key: str, namespace: str = "default") -> Any | None:
52
+ if not self._conn:
53
+ await self.connect()
54
+ cursor = await self._conn.execute(
55
+ "SELECT value FROM kv_store WHERE key = ? AND namespace = ?",
56
+ (key, namespace),
57
+ )
58
+ row = await cursor.fetchone()
59
+ if row:
60
+ return json.loads(row[0])
61
+ return None
62
+
63
+ async def write(self, key: str, value: Any, namespace: str = "default") -> bool:
64
+ if not self._conn:
65
+ await self.connect()
66
+ await self._conn.execute(
67
+ "INSERT OR REPLACE INTO kv_store (key, value, namespace) VALUES (?, ?, ?)",
68
+ (key, json.dumps(value), namespace),
69
+ )
70
+ await self._conn.commit()
71
+ return True
72
+
73
+ async def delete(self, key: str, namespace: str = "default") -> bool:
74
+ if not self._conn:
75
+ await self.connect()
76
+ cursor = await self._conn.execute(
77
+ "DELETE FROM kv_store WHERE key = ? AND namespace = ?",
78
+ (key, namespace),
79
+ )
80
+ await self._conn.commit()
81
+ return cursor.rowcount > 0
82
+
83
+ async def list_keys(self, namespace: str = "default") -> list[str]:
84
+ if not self._conn:
85
+ await self.connect()
86
+ cursor = await self._conn.execute(
87
+ "SELECT key FROM kv_store WHERE namespace = ?",
88
+ (namespace,),
89
+ )
90
+ rows = await cursor.fetchall()
91
+ return [row[0] for row in rows]
92
+
93
+
94
+ def create_storage(db_path: str = "evoid.db") -> SQLiteStorage:
95
+ """Factory: create a SQLite storage instance."""
96
+ return SQLiteStorage(db_path=db_path)
97
+
98
+
99
+ def register_plugin():
100
+ """Called when the plugin is loaded."""
101
+ register(
102
+ name="sqlite",
103
+ type="engine",
104
+ factory=create_storage,
105
+ version="0.1.0",
106
+ description="SQLite storage engine for EVOID",
107
+ )
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "evoid-sqlite",
3
+ "version": "0.1.0",
4
+ "type": "engine",
5
+ "description": "SQLite storage engine for EVOID",
6
+ "entry_point": "evoid_sqlite:register_plugin",
7
+ "dependencies": ["aiosqlite>=0.20.0"],
8
+ "evoid_version": ">=0.4.0",
9
+ "tags": ["storage", "sqlite", "database"]
10
+ }
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: evoid-sqlite
3
+ Version: 0.1.0
4
+ Summary: SQLite storage engine for EVOID
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.12
7
+ Requires-Dist: aiosqlite>=0.20.0
8
+ Requires-Dist: evoid>=0.4.0
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest; extra == 'dev'
11
+ Requires-Dist: pytest-asyncio; extra == 'dev'
12
+ Requires-Dist: ruff; extra == 'dev'
@@ -0,0 +1,5 @@
1
+ evoid_sqlite/__init__.py,sha256=-veEIBkeNSXwEY60z-_OOahUDaxMdxwPXuyqIguYK2A,3138
2
+ evoid_sqlite/evoid_plugin.json,sha256=7L8NAaTsLHKx6Cth1TWcFmsMR2R-ZUtLYhutfiTFGdM,288
3
+ evoid_sqlite-0.1.0.dist-info/METADATA,sha256=4UjDn7_x3MiBwMUnZL7kAh8nTdM_3g-vntx-sTU694Y,346
4
+ evoid_sqlite-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
5
+ evoid_sqlite-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any