surreal-orm-lite 0.2.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.
- surreal_orm_lite/__init__.py +24 -0
- surreal_orm_lite/connection_manager.py +313 -0
- surreal_orm_lite/constants.py +20 -0
- surreal_orm_lite/enum.py +12 -0
- surreal_orm_lite/exceptions.py +54 -0
- surreal_orm_lite/model_base.py +212 -0
- surreal_orm_lite/py.typed +0 -0
- surreal_orm_lite/query_set.py +503 -0
- surreal_orm_lite/utils.py +6 -0
- surreal_orm_lite-0.2.0.dist-info/METADATA +283 -0
- surreal_orm_lite-0.2.0.dist-info/RECORD +13 -0
- surreal_orm_lite-0.2.0.dist-info/WHEEL +4 -0
- surreal_orm_lite-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: surreal-orm-lite
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Lightweight Django-style ORM for SurrealDB using the official Python SDK. Async support with Pydantic validation.
|
|
5
|
+
Project-URL: Homepage, https://github.com/EulogySnowfall/surreal-orm-lite
|
|
6
|
+
Project-URL: Documentation, https://github.com/EulogySnowfall/surreal-orm-lite
|
|
7
|
+
Project-URL: Repository, https://github.com/EulogySnowfall/surreal-orm-lite.git
|
|
8
|
+
Project-URL: Issues, https://github.com/EulogySnowfall/surreal-orm-lite/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/EulogySnowfall/surreal-orm-lite/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Yannick Croteau <croteau.yannick@gmail.com>
|
|
11
|
+
License: # MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2024-2026 Yannick Croteau
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: async,database,orm,pydantic,surrealdb
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Framework :: Pydantic :: 2
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
43
|
+
Classifier: Topic :: Database
|
|
44
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
45
|
+
Classifier: Typing :: Typed
|
|
46
|
+
Requires-Python: >=3.11
|
|
47
|
+
Requires-Dist: pydantic>=2.12.5
|
|
48
|
+
Requires-Dist: surrealdb>=1.0.8
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# Surreal ORM Lite
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+

|
|
55
|
+

|
|
56
|
+

|
|
57
|
+
[](https://codecov.io/gh/EulogySnowfall/SurrealDB-ORM-lite)
|
|
58
|
+
|
|
59
|
+
**Surreal ORM Lite** is a lightweight, Django-style ORM for [SurrealDB](https://surrealdb.com/) that uses the **official SurrealDB Python SDK**. It provides a simple and intuitive interface for database operations with full async support and Pydantic validation.
|
|
60
|
+
|
|
61
|
+
## Why This Project?
|
|
62
|
+
|
|
63
|
+
This ORM is designed to:
|
|
64
|
+
|
|
65
|
+
- Use the **official SurrealDB SDK** (`surrealdb>=1.0.8`) for maximum compatibility
|
|
66
|
+
- Stay **lightweight** with minimal dependencies
|
|
67
|
+
- Keep **up-to-date** with SurrealDB and SDK releases
|
|
68
|
+
- Provide **Django-style** query syntax that developers love
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Requirements
|
|
73
|
+
|
|
74
|
+
| Dependency | Version |
|
|
75
|
+
| ------------ | ---------------- |
|
|
76
|
+
| Python | 3.11+ |
|
|
77
|
+
| SurrealDB | 2.6.0+ |
|
|
78
|
+
| Official SDK | surrealdb>=1.0.8 |
|
|
79
|
+
| Pydantic | >=2.12.5 |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install surreal-orm-lite
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Or with uv:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
uv add surreal-orm-lite
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
### 1. Configure the Connection
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from surreal_orm_lite import SurrealDBConnectionManager
|
|
103
|
+
|
|
104
|
+
SurrealDBConnectionManager.set_connection(
|
|
105
|
+
url="http://localhost:8000",
|
|
106
|
+
user="root",
|
|
107
|
+
password="root",
|
|
108
|
+
namespace="my_namespace",
|
|
109
|
+
database="my_database",
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 2. Define a Model
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from surreal_orm_lite import BaseSurrealModel
|
|
117
|
+
from pydantic import Field
|
|
118
|
+
|
|
119
|
+
class User(BaseSurrealModel):
|
|
120
|
+
id: str | None = None
|
|
121
|
+
name: str = Field(..., max_length=100)
|
|
122
|
+
email: str
|
|
123
|
+
age: int = Field(..., ge=0)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 3. CRUD Operations
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Create
|
|
130
|
+
user = User(name="Alice", email="alice@example.com", age=30)
|
|
131
|
+
await user.save()
|
|
132
|
+
|
|
133
|
+
# Read
|
|
134
|
+
user = await User.objects().get("alice_id")
|
|
135
|
+
users = await User.objects().filter(age__gte=18).exec()
|
|
136
|
+
|
|
137
|
+
# Update
|
|
138
|
+
user.age = 31
|
|
139
|
+
await user.update()
|
|
140
|
+
|
|
141
|
+
# Or partial update
|
|
142
|
+
await user.merge(age=31)
|
|
143
|
+
|
|
144
|
+
# Delete
|
|
145
|
+
await user.delete()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 4. QuerySet Methods
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
# Filter with Django-style lookups
|
|
152
|
+
users = await User.objects().filter(
|
|
153
|
+
age__gte=18,
|
|
154
|
+
name__startswith="A"
|
|
155
|
+
).exec()
|
|
156
|
+
|
|
157
|
+
# Ordering
|
|
158
|
+
users = await User.objects().order_by("name").exec()
|
|
159
|
+
users = await User.objects().order_by("age", OrderBy.DESC).exec()
|
|
160
|
+
|
|
161
|
+
# Pagination
|
|
162
|
+
users = await User.objects().limit(10).offset(20).exec()
|
|
163
|
+
|
|
164
|
+
# Select specific fields
|
|
165
|
+
results = await User.objects().select("name", "email").exec()
|
|
166
|
+
|
|
167
|
+
# Get first result
|
|
168
|
+
user = await User.objects().filter(name="Alice").first()
|
|
169
|
+
|
|
170
|
+
# Get all records
|
|
171
|
+
all_users = await User.objects().all()
|
|
172
|
+
|
|
173
|
+
# Custom query
|
|
174
|
+
results = await User.objects().query(
|
|
175
|
+
"SELECT * FROM User WHERE age > $min_age",
|
|
176
|
+
{"min_age": 21}
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Features
|
|
183
|
+
|
|
184
|
+
| Feature | Status |
|
|
185
|
+
| --------------------- | ------ |
|
|
186
|
+
| Async/await support | ✅ |
|
|
187
|
+
| Pydantic validation | ✅ |
|
|
188
|
+
| CRUD operations | ✅ |
|
|
189
|
+
| QuerySet with filters | ✅ |
|
|
190
|
+
| Django-style lookups | ✅ |
|
|
191
|
+
| Custom primary keys | ✅ |
|
|
192
|
+
| HTTP connections | ✅ |
|
|
193
|
+
| WebSocket connections | ✅ |
|
|
194
|
+
|
|
195
|
+
### Supported Filter Lookups
|
|
196
|
+
|
|
197
|
+
- `exact` (default)
|
|
198
|
+
- `gt`, `gte`, `lt`, `lte`
|
|
199
|
+
- `in`
|
|
200
|
+
- `contains`, `icontains`
|
|
201
|
+
- `startswith`, `istartswith`
|
|
202
|
+
- `endswith`, `iendswith`
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Configuration Options
|
|
207
|
+
|
|
208
|
+
### Custom Primary Key
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from surreal_orm_lite import BaseSurrealModel, SurrealConfigDict
|
|
212
|
+
|
|
213
|
+
class Product(BaseSurrealModel):
|
|
214
|
+
model_config = SurrealConfigDict(primary_key="sku")
|
|
215
|
+
|
|
216
|
+
sku: str
|
|
217
|
+
name: str
|
|
218
|
+
price: float
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Context Manager
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
async with SurrealDBConnectionManager():
|
|
225
|
+
users = await User.objects().all()
|
|
226
|
+
# Connection automatically closed
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Compatibility
|
|
232
|
+
|
|
233
|
+
This ORM is tested and compatible with:
|
|
234
|
+
|
|
235
|
+
| SurrealDB Version | SDK Version | Status |
|
|
236
|
+
| ----------------- | ----------- | ------------- |
|
|
237
|
+
| 2.6.0 | 1.0.8 | ✅ Tested |
|
|
238
|
+
| 2.5.x | 1.0.8 | ✅ Compatible |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Contributing
|
|
243
|
+
|
|
244
|
+
Contributions are welcome! Please:
|
|
245
|
+
|
|
246
|
+
1. Fork the repository
|
|
247
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
248
|
+
3. Commit your changes (`git commit -m "Add amazing feature"`)
|
|
249
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
250
|
+
5. Open a Pull Request
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Advanced Features?
|
|
255
|
+
|
|
256
|
+
This project prioritizes **stability and compatibility** with the official SurrealDB Python SDK. Due to current SDK limitations, some advanced features cannot be implemented here.
|
|
257
|
+
|
|
258
|
+
For a feature-rich ORM with relations, transactions, and more, see:
|
|
259
|
+
|
|
260
|
+
- **GitHub**: [SurrealDB-ORM](https://github.com/EulogySnowfall/SurrealDB-ORM/)
|
|
261
|
+
- **PyPI**: [surrealdb-orm](https://pypi.org/project/surrealdb-orm/)
|
|
262
|
+
|
|
263
|
+
When the official SDK supports additional features, they will be incorporated into this lite version.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Author
|
|
274
|
+
|
|
275
|
+
**Yannick Croteau**
|
|
276
|
+
GitHub: [@EulogySnowfall](https://github.com/EulogySnowfall)
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Related Projects
|
|
281
|
+
|
|
282
|
+
- [SurrealDB](https://surrealdb.com/) - The database
|
|
283
|
+
- [surrealdb.py](https://github.com/surrealdb/surrealdb.py) - Official Python SDK
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
surreal_orm_lite/__init__.py,sha256=x2IIvuS9qlW36ynKLCu9OVKdWmRJBU8mL_x4z-EhGjU,602
|
|
2
|
+
surreal_orm_lite/connection_manager.py,sha256=eWW0__ysAxE041y5cRmNXLRU5HR-V7UY6ggP2LnWITs,8915
|
|
3
|
+
surreal_orm_lite/constants.py,sha256=CLavEca1M6cLJLqVl4l4KoE-cBrgVQNsuGxW9zGJBmg,429
|
|
4
|
+
surreal_orm_lite/enum.py,sha256=kR-vzkHqnqy9YaYOvWTwAHdl2-WCzPcSEch-YTyJv1Y,158
|
|
5
|
+
surreal_orm_lite/exceptions.py,sha256=nS0H1zVdiQUq9anQhwjOGZoQbTf93c7_uQbbqfSvKg4,1010
|
|
6
|
+
surreal_orm_lite/model_base.py,sha256=P-Ua1QDXD-SEPiDBIBazX9nU06M7LWZe-Tk7uuYsCic,6633
|
|
7
|
+
surreal_orm_lite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
surreal_orm_lite/query_set.py,sha256=cIKVMzGLKFndXtZuChjJmTGkzT1ocbS72pWWMo9VdXw,18680
|
|
9
|
+
surreal_orm_lite/utils.py,sha256=mni_dTtb4VGTdge8eWSZpBw5xoWci2m-XThKFHYPKTo,171
|
|
10
|
+
surreal_orm_lite-0.2.0.dist-info/METADATA,sha256=W-Bv7U_RI4HIZYmCsqJ1pV1dVm4aHN1PtwEnm9jlHDE,8013
|
|
11
|
+
surreal_orm_lite-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
12
|
+
surreal_orm_lite-0.2.0.dist-info/licenses/LICENSE,sha256=Rvt8jJeCkvea8PDJ6svk6p5oMXzo_EJI1m-Avs1aTlg,1079
|
|
13
|
+
surreal_orm_lite-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Yannick Croteau
|
|
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.
|