surrealdb-orm 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.

Potentially problematic release.


This version of surrealdb-orm might be problematic. Click here for more details.

@@ -0,0 +1,79 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ .windsurfrules
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ dist/
13
+ build/
14
+ *.egg-info/
15
+ *.egg
16
+ MANIFEST
17
+ wheels/
18
+ *.whl
19
+
20
+ # Unit test / coverage reports
21
+ htmlcov/
22
+ .tox/
23
+ .nox/
24
+ .coverage
25
+ .coverage.*
26
+ coverage.xml
27
+ junit.xml
28
+ *.cover
29
+ *.py,cover
30
+ .pytest_cache/
31
+ .hypothesis/
32
+
33
+ # Jupyter Notebook
34
+ .ipynb_checkpoints
35
+ *.ipynb
36
+
37
+ # Environment directories
38
+ .env
39
+ .dev-venv
40
+ .venv
41
+ .venv*/
42
+ env/
43
+ venv/
44
+ ENV/
45
+
46
+ # IDE settings
47
+ .idea/
48
+ .vscode/
49
+ *.swp
50
+ *.swo
51
+ .project
52
+ .pydevproject
53
+ .settings/
54
+ *.sublime-workspace
55
+ *.sublime-project
56
+
57
+ # Logs and databases
58
+ *.log
59
+ *.sqlite
60
+ *.db
61
+ surreal_data/
62
+
63
+ # OS generated files
64
+ .DS_Store
65
+ .DS_Store?
66
+ ._*
67
+ .Spotlight-V100
68
+ .Trashes
69
+ ehthumbs.db
70
+ Thumbs.db
71
+
72
+ # Project specific
73
+ external_pkg_ref/
74
+ *.bak
75
+ *.tmp
76
+ .mypy_cache/
77
+ .ruff_cache/
78
+ .dmypy.json
79
+ dmypy.json
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2024 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.
@@ -0,0 +1,44 @@
1
+ .DEFAULT_GOAL := all
2
+ sources = src tests
3
+
4
+ .PHONY: .uv # Check that uv is installed
5
+ .uv:
6
+ @uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
7
+
8
+ .PHONY: install # Install the package, dependencies, and pre-commit for local development
9
+ install: .uv
10
+ uv sync --frozen --group lint
11
+ uv run pre-commit install --install-hooks
12
+
13
+ .PHONY: format # Format the code
14
+ format:
15
+ uv run ruff format
16
+ uv run ruff check --fix --fix-only
17
+
18
+ .PHONY: lint # Lint the code
19
+ lint:
20
+ uv run ruff format --check
21
+ uv run ruff check
22
+
23
+ .PHONY: typecheck
24
+ typecheck:
25
+ uv run pyright
26
+
27
+ .PHONY: test
28
+ test:
29
+ uv run pytest
30
+
31
+ .PHONY: test-all-python # Run tests on Python 3.11 to 3.13
32
+ test-all-python:
33
+ uv run --python 3.11 coverage run -p -m pytest --junitxml=junit.xml -o junit_family=legacy
34
+ UV_PROJECT_ENVIRONMENT=.venv312 uv run --python 3.12 coverage run -p -m pytest
35
+ UV_PROJECT_ENVIRONMENT=.venv313 uv run --python 3.13 coverage run -p -m pytest
36
+ @uv run coverage xml -o coverage.xml
37
+ @uv run coverage report
38
+
39
+ .PHONY: html # Generate HTML coverage report
40
+ html: test-all-python
41
+ uv run coverage html -d htmlcov
42
+
43
+ .PHONY: all
44
+ all: format lint typecheck test-all-python
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
2
+ Name: surrealdb-orm
3
+ Version: 0.1.0
4
+ Summary: SurrealDB ORM as 'DJango style' for Python with async support. Works with pydantic validation.
5
+ Project-URL: Homepage, https://github.com/EulogySnowfall/SurrealDB-ORM
6
+ Project-URL: Documentation, https://github.com/EulogySnowfall/SurrealDB-ORM
7
+ Project-URL: Repository, https://github.com/EulogySnowfall/SurrealDB-ORM.git
8
+ Project-URL: Issues, https://github.com/EulogySnowfall/SurrealDB-ORM/issues
9
+ Author-email: Yannick Croteau <yannick.croteau@gmail.com>
10
+ License: # MIT License
11
+
12
+ Copyright (c) 2024 Yannick Croteau
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Topic :: Database
40
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
41
+ Requires-Python: >=3.11
42
+ Requires-Dist: pydantic>=2.10.4
43
+ Requires-Dist: surrealdb>=0.4.1
44
+ Description-Content-Type: text/markdown
45
+
46
+ # SurrealDB-ORM
47
+
48
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
49
+ ![CI](https://github.com/EulogySnowfall/SurrealDB-ORM/actions/workflows/ci.yml/badge.svg)
50
+ [![codecov](https://codecov.io/gh/EulogySnowfall/SurrealDB-ORM/graph/badge.svg?token=XUONTG2M6Z)](https://codecov.io/gh/EulogySnowfall/SurrealDB-ORM)
51
+ ![GitHub License](https://img.shields.io/github/license/EulogySnowfall/SurrealDB-ORM)
52
+
53
+ 🚀 **SurrealDB-ORM** is a lightweight ORM (Object-Relational Mapping) inspired by Django ORM, designed to simplify interactions with **SurrealDB** in Python projects. It provides an intuitive way to manage models, perform queries, and execute CRUD (Create, Read, Update, Delete) operations.
54
+
55
+ ---
56
+
57
+ ## 📋 Table of Contents
58
+
59
+ - [Version](#-version)
60
+ - [Description](#-description)
61
+ - [Requirements and tested based](#-requirements-and-tested-based)
62
+ - [Installation](#-installation)
63
+ - [Usage Example](#-usage-example)
64
+ - [Features](#-features)
65
+ - [Contributing](#-contributing)
66
+ - [TODO](#-todo)
67
+ - [License](#-license)
68
+
69
+ ---
70
+
71
+ ## :white_check_mark: Version
72
+
73
+ Alpha 0.1.0
74
+
75
+ ---
76
+
77
+ ## 📝 Description
78
+
79
+ SurrealDB-ORM offers a clean abstraction for handling SurrealDB through Python models.
80
+ The goal is to simplify writing complex queries while providing an intuitive interface similar to modern ORMs like Django or SQLAlchemy.
81
+
82
+ ---
83
+
84
+ ## 📝 Requirements and tested based
85
+
86
+ - Python : 3.11~3.13
87
+ - Pydantic : 2.10.4
88
+ - SurrealDB Database Version : 2.1.4
89
+ - You need to set a SurrealDB to connect to.
90
+
91
+ ---
92
+
93
+ ## 🛠️ Installation
94
+
95
+ ```bash
96
+ pip install surrealdb-orm
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 🚀 Usage Example
102
+
103
+ Here's a simple example demonstrating how to define a model and interact with SurrealDB:
104
+
105
+ ### 1. Define a Model
106
+
107
+ ```python
108
+ from surreal_orm.modelBase import BaseSurrealModel
109
+ from pydantic import BaseModel, Field
110
+ from typing import Optional
111
+
112
+
113
+ class User(BaseSurrealModel):
114
+ id: Optional[str] = None
115
+ name: str = Field(..., max_length=100)
116
+ email: str
117
+ ```
118
+
119
+ ### 2. Create and Save a User
120
+
121
+ ```python
122
+ user = User(name="Alice", email="alice@example.com")
123
+ await user.save()
124
+ ```
125
+
126
+ ### 3. Query Users
127
+
128
+ ```python
129
+ users = await User.objects().filter(name="Alice").exec()
130
+ for user in users:
131
+ print(user.name, user.email)
132
+ ```
133
+
134
+ ---
135
+
136
+ ## 🌟 Features
137
+
138
+ - 🔧 **Model definition** using Pydantic
139
+ - 📄 **QuerySet** with filter methods like `filter()`, `limit()`, and `order_by()`
140
+ - 🔄 **CRUD** operations (Create, Read, Update, Delete)
141
+ - ⚙️ **Asynchronous connection** to SurrealDB
142
+ - 🔍 **Automatic validation** with Pydantic
143
+ - 📊 **Complex queries** with conditional filters (`age__gte`, `name__in`, etc.)
144
+
145
+ ---
146
+
147
+ ## 🤝 Contributing
148
+
149
+ Contributions are welcome!
150
+ If you'd like to improve this project:
151
+
152
+ 1. Fork the repository.
153
+ 2. Create a branch (`git checkout -b feature/new-feature`).
154
+ 3. Make your changes and commit them (`git commit -m "Add new feature"`).
155
+ 4. Push to your branch (`git push origin feature/new-feature`).
156
+ 5. Create a Pull Request.
157
+
158
+ ---
159
+
160
+ ## 📌 TODO
161
+
162
+ - [ ] Implement relationships
163
+ - [ ] Add transaction support
164
+ - [ ] Optimize complex queries
165
+ - [ ] Expand documentation with advanced examples
166
+ - [ ] Better SurrealQL Integration
167
+
168
+ ---
169
+
170
+ ## 📄 License
171
+
172
+ This project is licensed under the **MIT License**. See the `LICENSE` file for more information.
173
+
174
+ ---
175
+
176
+ ### 📨 Contact
177
+
178
+ **Author:** Yannick Croteau
179
+ **Email:** <croteau.yannick@gmail.com>
180
+ **GitHub:** [EulogySnowfall](https://github.com/EulogySnowfall)
181
+
182
+ ---
183
+
184
+ **SurrealDB-ORM** is a personal package to use with other projects. I will certainly improve it over the next few months, but feel free to open issues or suggest improvements 🚀
@@ -0,0 +1,139 @@
1
+ # SurrealDB-ORM
2
+
3
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
4
+ ![CI](https://github.com/EulogySnowfall/SurrealDB-ORM/actions/workflows/ci.yml/badge.svg)
5
+ [![codecov](https://codecov.io/gh/EulogySnowfall/SurrealDB-ORM/graph/badge.svg?token=XUONTG2M6Z)](https://codecov.io/gh/EulogySnowfall/SurrealDB-ORM)
6
+ ![GitHub License](https://img.shields.io/github/license/EulogySnowfall/SurrealDB-ORM)
7
+
8
+ 🚀 **SurrealDB-ORM** is a lightweight ORM (Object-Relational Mapping) inspired by Django ORM, designed to simplify interactions with **SurrealDB** in Python projects. It provides an intuitive way to manage models, perform queries, and execute CRUD (Create, Read, Update, Delete) operations.
9
+
10
+ ---
11
+
12
+ ## 📋 Table of Contents
13
+
14
+ - [Version](#-version)
15
+ - [Description](#-description)
16
+ - [Requirements and tested based](#-requirements-and-tested-based)
17
+ - [Installation](#-installation)
18
+ - [Usage Example](#-usage-example)
19
+ - [Features](#-features)
20
+ - [Contributing](#-contributing)
21
+ - [TODO](#-todo)
22
+ - [License](#-license)
23
+
24
+ ---
25
+
26
+ ## :white_check_mark: Version
27
+
28
+ Alpha 0.1.0
29
+
30
+ ---
31
+
32
+ ## 📝 Description
33
+
34
+ SurrealDB-ORM offers a clean abstraction for handling SurrealDB through Python models.
35
+ The goal is to simplify writing complex queries while providing an intuitive interface similar to modern ORMs like Django or SQLAlchemy.
36
+
37
+ ---
38
+
39
+ ## 📝 Requirements and tested based
40
+
41
+ - Python : 3.11~3.13
42
+ - Pydantic : 2.10.4
43
+ - SurrealDB Database Version : 2.1.4
44
+ - You need to set a SurrealDB to connect to.
45
+
46
+ ---
47
+
48
+ ## 🛠️ Installation
49
+
50
+ ```bash
51
+ pip install surrealdb-orm
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 🚀 Usage Example
57
+
58
+ Here's a simple example demonstrating how to define a model and interact with SurrealDB:
59
+
60
+ ### 1. Define a Model
61
+
62
+ ```python
63
+ from surreal_orm.modelBase import BaseSurrealModel
64
+ from pydantic import BaseModel, Field
65
+ from typing import Optional
66
+
67
+
68
+ class User(BaseSurrealModel):
69
+ id: Optional[str] = None
70
+ name: str = Field(..., max_length=100)
71
+ email: str
72
+ ```
73
+
74
+ ### 2. Create and Save a User
75
+
76
+ ```python
77
+ user = User(name="Alice", email="alice@example.com")
78
+ await user.save()
79
+ ```
80
+
81
+ ### 3. Query Users
82
+
83
+ ```python
84
+ users = await User.objects().filter(name="Alice").exec()
85
+ for user in users:
86
+ print(user.name, user.email)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 🌟 Features
92
+
93
+ - 🔧 **Model definition** using Pydantic
94
+ - 📄 **QuerySet** with filter methods like `filter()`, `limit()`, and `order_by()`
95
+ - 🔄 **CRUD** operations (Create, Read, Update, Delete)
96
+ - ⚙️ **Asynchronous connection** to SurrealDB
97
+ - 🔍 **Automatic validation** with Pydantic
98
+ - 📊 **Complex queries** with conditional filters (`age__gte`, `name__in`, etc.)
99
+
100
+ ---
101
+
102
+ ## 🤝 Contributing
103
+
104
+ Contributions are welcome!
105
+ If you'd like to improve this project:
106
+
107
+ 1. Fork the repository.
108
+ 2. Create a branch (`git checkout -b feature/new-feature`).
109
+ 3. Make your changes and commit them (`git commit -m "Add new feature"`).
110
+ 4. Push to your branch (`git push origin feature/new-feature`).
111
+ 5. Create a Pull Request.
112
+
113
+ ---
114
+
115
+ ## 📌 TODO
116
+
117
+ - [ ] Implement relationships
118
+ - [ ] Add transaction support
119
+ - [ ] Optimize complex queries
120
+ - [ ] Expand documentation with advanced examples
121
+ - [ ] Better SurrealQL Integration
122
+
123
+ ---
124
+
125
+ ## 📄 License
126
+
127
+ This project is licensed under the **MIT License**. See the `LICENSE` file for more information.
128
+
129
+ ---
130
+
131
+ ### 📨 Contact
132
+
133
+ **Author:** Yannick Croteau
134
+ **Email:** <croteau.yannick@gmail.com>
135
+ **GitHub:** [EulogySnowfall](https://github.com/EulogySnowfall)
136
+
137
+ ---
138
+
139
+ **SurrealDB-ORM** is a personal package to use with other projects. I will certainly improve it over the next few months, but feel free to open issues or suggest improvements 🚀
@@ -0,0 +1,93 @@
1
+ [project]
2
+ name = "surrealdb-orm"
3
+ version = "0.1.0"
4
+ description = "SurrealDB ORM as 'DJango style' for Python with async support. Works with pydantic validation."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = {file = "LICENSE"}
8
+ authors = [
9
+ { name = "Yannick Croteau", email = "yannick.croteau@gmail.com" }
10
+ ]
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Programming Language :: Python :: 3.13",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Topic :: Database",
19
+ "Topic :: Software Development :: Libraries :: Python Modules",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+
23
+ dependencies = [
24
+ "pydantic>=2.10.4",
25
+ "surrealdb>=0.4.1",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/EulogySnowfall/SurrealDB-ORM"
30
+ Documentation = "https://github.com/EulogySnowfall/SurrealDB-ORM"
31
+ Repository = "https://github.com/EulogySnowfall/SurrealDB-ORM.git"
32
+ Issues = "https://github.com/EulogySnowfall/SurrealDB-ORM/issues"
33
+
34
+ [tool.setuptools]
35
+ packages = ["src.surrealdb_orm"]
36
+
37
+
38
+ [build-system]
39
+ requires = ["hatchling"]
40
+ build-backend = "hatchling.build"
41
+
42
+ [tool.ruff]
43
+ line-length = 128
44
+ target-version = "py311"
45
+
46
+ [tool.mypy]
47
+ python_version = "3.11"
48
+ warn_return_any = true
49
+ warn_unused_configs = true
50
+ disallow_untyped_defs = true
51
+ check_untyped_defs = true
52
+ exclude = "^(tests|examples)/"
53
+
54
+ [[tool.mypy.overrides]]
55
+ module = ["surrealdb.*"]
56
+ ignore_missing_imports = true
57
+ no_implicit_reexport = true
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ python_files = ["test_*.py"]
62
+ addopts = "-ra -q --cov=src.surreal_orm --cov-branch --cov-report=xml --cov-report=html --cov-report=term-missing --cov-fail-under=70 --cov-context=test"
63
+ asyncio_mode = "auto"
64
+ asyncio_default_fixture_loop_scope = "module"
65
+ # log_cli = true
66
+
67
+ [tool.pyright]
68
+ include = ["src"]
69
+
70
+ [dependency-groups]
71
+ dev = [
72
+ "ipykernel>=6.29.5",
73
+ "mypy>=1.14.0",
74
+ "pytest>=8.3.4",
75
+ "pytest-asyncio>=0.25.0",
76
+ "pytest-cov>=6.0.0",
77
+ "black>=24.10.0",
78
+ "pydantic>=2.10.4",
79
+ "docker>=7.1.0",
80
+ "isort>=5.13.2",
81
+ "flake8>=7.1.1",
82
+ "python-dotenv>=1.0.1",
83
+ ]
84
+ lint = [
85
+ "ruff>=0.8.4",
86
+ ]
87
+
88
+
89
+ [tool.hatch.build.targets.wheel]
90
+ packages = ["src"]
91
+
92
+ [tool.hatch.build.targets.sdist]
93
+ include = ["/README.md", "/Makefile", "/src", "/tests"]
@@ -0,0 +1,3 @@
1
+ from .surreal_orm import BaseSurrealModel, SurrealDBConnectionManager, QuerySet
2
+
3
+ __all__ = ["BaseSurrealModel", "SurrealDBConnectionManager", "QuerySet"]
@@ -0,0 +1,6 @@
1
+ from .model_base import BaseSurrealModel
2
+ from .connection_manager import SurrealDBConnectionManager
3
+ from .query_set import QuerySet
4
+ from .enum import OrderBy
5
+
6
+ __all__ = ["SurrealDBConnectionManager", "BaseSurrealModel", "QuerySet", "OrderBy"]