matrx-orm 1.0.4__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.
Files changed (92) hide show
  1. matrx_orm-1.0.4/.env.example +12 -0
  2. matrx_orm-1.0.4/.github/workflows/publish.yml +54 -0
  3. matrx_orm-1.0.4/.gitignore +206 -0
  4. matrx_orm-1.0.4/.python-version +1 -0
  5. matrx_orm-1.0.4/PKG-INFO +93 -0
  6. matrx_orm-1.0.4/README.md +81 -0
  7. matrx_orm-1.0.4/main.py +0 -0
  8. matrx_orm-1.0.4/pyproject.toml +29 -0
  9. matrx_orm-1.0.4/src/matrx_orm/__init__.py +16 -0
  10. matrx_orm-1.0.4/src/matrx_orm/adapters/__init__.py +0 -0
  11. matrx_orm-1.0.4/src/matrx_orm/adapters/base_adapter.py +69 -0
  12. matrx_orm-1.0.4/src/matrx_orm/adapters/postgresql.py +171 -0
  13. matrx_orm-1.0.4/src/matrx_orm/client/__init__.py +1 -0
  14. matrx_orm-1.0.4/src/matrx_orm/client/postgres_connection.py +144 -0
  15. matrx_orm-1.0.4/src/matrx_orm/constants.py +141 -0
  16. matrx_orm-1.0.4/src/matrx_orm/core/__init__.py +0 -0
  17. matrx_orm-1.0.4/src/matrx_orm/core/async_db_manager.py +222 -0
  18. matrx_orm-1.0.4/src/matrx_orm/core/base.py +663 -0
  19. matrx_orm-1.0.4/src/matrx_orm/core/config.py +366 -0
  20. matrx_orm-1.0.4/src/matrx_orm/core/expressions.py +22 -0
  21. matrx_orm-1.0.4/src/matrx_orm/core/extended.py +1205 -0
  22. matrx_orm-1.0.4/src/matrx_orm/core/fields.py +850 -0
  23. matrx_orm-1.0.4/src/matrx_orm/core/registry.py +43 -0
  24. matrx_orm-1.0.4/src/matrx_orm/core/relations.py +260 -0
  25. matrx_orm-1.0.4/src/matrx_orm/error_handling.py +46 -0
  26. matrx_orm-1.0.4/src/matrx_orm/exceptions.py +256 -0
  27. matrx_orm-1.0.4/src/matrx_orm/extended/__init__.py +0 -0
  28. matrx_orm-1.0.4/src/matrx_orm/extended/app_error_handler.py +101 -0
  29. matrx_orm-1.0.4/src/matrx_orm/middleware/__init__.py +0 -0
  30. matrx_orm-1.0.4/src/matrx_orm/middleware/base.py +249 -0
  31. matrx_orm-1.0.4/src/matrx_orm/operations/__init__.py +0 -0
  32. matrx_orm-1.0.4/src/matrx_orm/operations/create.py +118 -0
  33. matrx_orm-1.0.4/src/matrx_orm/operations/delete.py +59 -0
  34. matrx_orm-1.0.4/src/matrx_orm/operations/read.py +59 -0
  35. matrx_orm-1.0.4/src/matrx_orm/operations/update.py +165 -0
  36. matrx_orm-1.0.4/src/matrx_orm/python_sql/__init__.py +0 -0
  37. matrx_orm-1.0.4/src/matrx_orm/python_sql/db_objects.py +389 -0
  38. matrx_orm-1.0.4/src/matrx_orm/python_sql/table_detailed_relationships.py +498 -0
  39. matrx_orm-1.0.4/src/matrx_orm/python_sql/table_typescript_relationship.py +180 -0
  40. matrx_orm-1.0.4/src/matrx_orm/query/__init__.py +0 -0
  41. matrx_orm-1.0.4/src/matrx_orm/query/builder.py +249 -0
  42. matrx_orm-1.0.4/src/matrx_orm/query/executor.py +376 -0
  43. matrx_orm-1.0.4/src/matrx_orm/schema_builder/__init__.py +1 -0
  44. matrx_orm-1.0.4/src/matrx_orm/schema_builder/generator.py +149 -0
  45. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/__init__.py +0 -0
  46. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/configs.py +0 -0
  47. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/git_checker.py +118 -0
  48. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/manager_dto_creator.py +435 -0
  49. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/manager_helpers.py +22 -0
  50. matrx_orm-1.0.4/src/matrx_orm/schema_builder/helpers/manual_overrides.py +144 -0
  51. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/__init__.py +0 -0
  52. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/columns.py +1195 -0
  53. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/common.py +16 -0
  54. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/relationships.py +57 -0
  55. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/schema.py +722 -0
  56. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/tables.py +1116 -0
  57. matrx_orm-1.0.4/src/matrx_orm/schema_builder/individual_managers/views.py +94 -0
  58. matrx_orm-1.0.4/src/matrx_orm/schema_builder/parts_generators/__init__.py +0 -0
  59. matrx_orm-1.0.4/src/matrx_orm/schema_builder/parts_generators/entity_field_override_generator.py +137 -0
  60. matrx_orm-1.0.4/src/matrx_orm/schema_builder/parts_generators/entity_main_hook_generator.py +242 -0
  61. matrx_orm-1.0.4/src/matrx_orm/schema_builder/parts_generators/entity_override_generator.py +51 -0
  62. matrx_orm-1.0.4/src/matrx_orm/schema_builder/schema_manager.py +770 -0
  63. matrx_orm-1.0.4/src/matrx_orm/sql_executor/__init__.py +20 -0
  64. matrx_orm-1.0.4/src/matrx_orm/sql_executor/executor.py +164 -0
  65. matrx_orm-1.0.4/src/matrx_orm/sql_executor/queries.py +118 -0
  66. matrx_orm-1.0.4/src/matrx_orm/sql_executor/registry.py +52 -0
  67. matrx_orm-1.0.4/src/matrx_orm/sql_executor/types.py +18 -0
  68. matrx_orm-1.0.4/src/matrx_orm/sql_executor/utils.py +90 -0
  69. matrx_orm-1.0.4/src/matrx_orm/state.py +466 -0
  70. matrx_orm-1.0.4/src/matrx_orm/structure.md +110 -0
  71. matrx_orm-1.0.4/src/matrx_orm/utils/__init__.py +0 -0
  72. matrx_orm-1.0.4/src/matrx_orm/utils/sql_utils.py +57 -0
  73. matrx_orm-1.0.4/src/matrx_orm/utils/type_converters.py +101 -0
  74. matrx_orm-1.0.4/tests/__init__.py +0 -0
  75. matrx_orm-1.0.4/tests/database_project_config.py +89 -0
  76. matrx_orm-1.0.4/tests/generation_test.py +83 -0
  77. matrx_orm-1.0.4/tests/load_env_for_test.py +3 -0
  78. matrx_orm-1.0.4/tests/orm_tests/__init__.py +0 -0
  79. matrx_orm-1.0.4/tests/orm_tests/additional_tests.py +160 -0
  80. matrx_orm-1.0.4/tests/orm_tests/broker_manager_test.py +190 -0
  81. matrx_orm-1.0.4/tests/orm_tests/broker_manager_with_base.py +363 -0
  82. matrx_orm-1.0.4/tests/orm_tests/cache_management.py +28 -0
  83. matrx_orm-1.0.4/tests/orm_tests/core_model_tests.py +106 -0
  84. matrx_orm-1.0.4/tests/orm_tests/demo.py +554 -0
  85. matrx_orm-1.0.4/tests/orm_tests/junk.py +97 -0
  86. matrx_orm-1.0.4/tests/orm_tests/manager_test.py +140 -0
  87. matrx_orm-1.0.4/tests/orm_tests/recipe_test.py +83 -0
  88. matrx_orm-1.0.4/tests/orm_tests/relationship_trials.py +101 -0
  89. matrx_orm-1.0.4/tests/orm_tests/sample_test.py +38 -0
  90. matrx_orm-1.0.4/tests/orm_tests/test_error_handling.py +0 -0
  91. matrx_orm-1.0.4/tests/query_executor.py +54 -0
  92. matrx_orm-1.0.4/uv.lock +429 -0
@@ -0,0 +1,12 @@
1
+ BASE_DIR=D:/work/matrx/matrx-orm
2
+
3
+ SUPABASE_MATRX_URL=supabase_host_url
4
+ DB_HOST=host
5
+ DB_NAME=postgres
6
+ DB_PORT=6543
7
+ DB_USER=user
8
+ DB_PASS=password
9
+ SUPABASE_MATRX_JWT_SECRET=secret
10
+
11
+ ADMIN_PYTHON_ROOT=D:/work/matrx/matrx-orm/temp/python-app
12
+ ADMIN_TS_ROOT=D:/work/matrx/matrx-orm/temp/ts-app
@@ -0,0 +1,54 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # Required for trusted publishing
13
+ contents: read
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: '3.12'
23
+
24
+ - name: Install UV
25
+ uses: astral-sh/setup-uv@v4
26
+ with:
27
+ enable-cache: true
28
+
29
+ - name: Extract version from tag
30
+ id: get_version
31
+ run: |
32
+ TAG=${GITHUB_REF#refs/tags/v}
33
+ echo "VERSION=$TAG" >> $GITHUB_OUTPUT
34
+ echo "Publishing version: $TAG"
35
+
36
+ - name: Verify version matches pyproject.toml
37
+ run: |
38
+ TOML_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
39
+ if [ "${{ steps.get_version.outputs.VERSION }}" != "$TOML_VERSION" ]; then
40
+ echo "❌ Error: Git tag version (${{ steps.get_version.outputs.VERSION }}) doesn't match pyproject.toml version ($TOML_VERSION)"
41
+ exit 1
42
+ fi
43
+ echo "✅ Version verified: $TOML_VERSION"
44
+
45
+ - name: Build package
46
+ run: |
47
+ uv build
48
+
49
+ - name: Publish to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
51
+ with:
52
+ verbose: true
53
+ print-hash: true
54
+
@@ -0,0 +1,206 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ .idea/
169
+
170
+ # Abstra
171
+ # Abstra is an AI-powered process automation framework.
172
+ # Ignore directories containing user credentials, local state, and settings.
173
+ # Learn more at https://abstra.io/docs
174
+ .abstra/
175
+
176
+ # Visual Studio Code
177
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
178
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
179
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
180
+ # you could uncomment the following to ignore the enitre vscode folder
181
+ # .vscode/
182
+
183
+ # Ruff stuff:
184
+ .ruff_cache/
185
+
186
+ # PyPI configuration file
187
+ .pypirc
188
+
189
+ # Cursor
190
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
191
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
192
+ # refer to https://docs.cursor.com/context/ignore-files
193
+ .cursorignore
194
+ .cursorindexingignore
195
+
196
+ # Ignore all files in any temp directory and all subdirectories (unlimited depth)
197
+ **/temp/**/*
198
+
199
+ # But allow all directories in any temp folder and all subdirectories (unlimited depth)
200
+ !**/temp/**/
201
+
202
+ src/matrx_orm/schema_builder/database/**
203
+ src/matrx_orm/schema_builder/database
204
+
205
+
206
+ .history/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: matrx-orm
3
+ Version: 1.0.4
4
+ Summary: Add your description here
5
+ Author-email: jatin.b.rx3@gmail.com
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: asyncpg==0.30.0
8
+ Requires-Dist: gitpython>=3.1.44
9
+ Requires-Dist: matrx-utils>=1.0.2
10
+ Requires-Dist: psycopg2>=2.9.10
11
+ Description-Content-Type: text/markdown
12
+
13
+ # matrx-orm
14
+
15
+ ORM utilities for the Matrx platform.
16
+
17
+ ## Installation
18
+
19
+ ### From PyPI (recommended)
20
+
21
+ ```bash
22
+ pip install matrx-orm
23
+ # or with uv
24
+ uv add matrx-orm
25
+ ```
26
+
27
+ ### From GitHub (for development)
28
+
29
+ ```bash
30
+ pip install git+https://github.com/armanisadeghi/matrx-orm.git
31
+ ```
32
+
33
+ ## Publishing a New Version
34
+
35
+ ### Automated PyPI Publishing (Current Process)
36
+
37
+ The package automatically publishes to PyPI when you push a version tag. Here's the workflow:
38
+
39
+ 1. **Make and test your changes locally**
40
+ ```bash
41
+ # Test your changes
42
+ ```
43
+
44
+ 2. **Update the version in pyproject.toml**
45
+ ```toml
46
+ version = "1.0.5" # Increment appropriately
47
+ ```
48
+
49
+ 3. **Commit and push changes**
50
+ ```bash
51
+ git add .
52
+ git commit -m "Add new feature - v1.0.5"
53
+ git push origin main
54
+ ```
55
+
56
+ 4. **Create and push the version tag**
57
+ ```bash
58
+ git tag v1.0.5
59
+ git push origin v1.0.5
60
+ ```
61
+
62
+ 5. **GitHub Actions automatically:**
63
+ - Verifies the tag matches pyproject.toml version
64
+ - Builds the package
65
+ - Publishes to PyPI
66
+
67
+ 6. **Update dependent projects**
68
+
69
+ In projects like AI Dream, simply update the version:
70
+ ```bash
71
+ uv add matrx-orm@1.0.5
72
+ # or manually in pyproject.toml:
73
+ # matrx-orm = "^1.0.5"
74
+ ```
75
+
76
+ ### Version History
77
+
78
+ Check current tags: `git tag`
79
+
80
+ Example output:
81
+ ```
82
+ v1.0.0
83
+ v1.0.2
84
+ v1.0.3
85
+ v1.0.4
86
+ ```
87
+
88
+ ### Important Notes
89
+
90
+ - **Always update pyproject.toml version before tagging**
91
+ - The GitHub Action will fail if tag version ≠ pyproject.toml version
92
+ - Semantic versioning: MAJOR.MINOR.PATCH (e.g., v1.0.5)
93
+ - Tags trigger automatic PyPI publishing
@@ -0,0 +1,81 @@
1
+ # matrx-orm
2
+
3
+ ORM utilities for the Matrx platform.
4
+
5
+ ## Installation
6
+
7
+ ### From PyPI (recommended)
8
+
9
+ ```bash
10
+ pip install matrx-orm
11
+ # or with uv
12
+ uv add matrx-orm
13
+ ```
14
+
15
+ ### From GitHub (for development)
16
+
17
+ ```bash
18
+ pip install git+https://github.com/armanisadeghi/matrx-orm.git
19
+ ```
20
+
21
+ ## Publishing a New Version
22
+
23
+ ### Automated PyPI Publishing (Current Process)
24
+
25
+ The package automatically publishes to PyPI when you push a version tag. Here's the workflow:
26
+
27
+ 1. **Make and test your changes locally**
28
+ ```bash
29
+ # Test your changes
30
+ ```
31
+
32
+ 2. **Update the version in pyproject.toml**
33
+ ```toml
34
+ version = "1.0.5" # Increment appropriately
35
+ ```
36
+
37
+ 3. **Commit and push changes**
38
+ ```bash
39
+ git add .
40
+ git commit -m "Add new feature - v1.0.5"
41
+ git push origin main
42
+ ```
43
+
44
+ 4. **Create and push the version tag**
45
+ ```bash
46
+ git tag v1.0.5
47
+ git push origin v1.0.5
48
+ ```
49
+
50
+ 5. **GitHub Actions automatically:**
51
+ - Verifies the tag matches pyproject.toml version
52
+ - Builds the package
53
+ - Publishes to PyPI
54
+
55
+ 6. **Update dependent projects**
56
+
57
+ In projects like AI Dream, simply update the version:
58
+ ```bash
59
+ uv add matrx-orm@1.0.5
60
+ # or manually in pyproject.toml:
61
+ # matrx-orm = "^1.0.5"
62
+ ```
63
+
64
+ ### Version History
65
+
66
+ Check current tags: `git tag`
67
+
68
+ Example output:
69
+ ```
70
+ v1.0.0
71
+ v1.0.2
72
+ v1.0.3
73
+ v1.0.4
74
+ ```
75
+
76
+ ### Important Notes
77
+
78
+ - **Always update pyproject.toml version before tagging**
79
+ - The GitHub Action will fail if tag version ≠ pyproject.toml version
80
+ - Semantic versioning: MAJOR.MINOR.PATCH (e.g., v1.0.5)
81
+ - Tags trigger automatic PyPI publishing
File without changes
@@ -0,0 +1,29 @@
1
+ [project]
2
+ name = "matrx-orm"
3
+ version = "1.0.4"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ { email = "jatin.b.rx3@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.10"
10
+ dependencies = [
11
+ "asyncpg==0.30.0",
12
+ "gitpython>=3.1.44",
13
+ "psycopg2>=2.9.10",
14
+ "matrx-utils>=1.0.2",
15
+ ]
16
+
17
+ [project.scripts]
18
+ matrx-orm = "matrx_orm:main"
19
+
20
+ [build-system]
21
+ requires = ["hatchling"]
22
+ build-backend = "hatchling.build"
23
+
24
+
25
+ [tool.hatch.build.targets.wheel]
26
+ packages = ["src/matrx_orm"]
27
+
28
+ [tool.hatch.metadata]
29
+ allow-direct-references = true
@@ -0,0 +1,16 @@
1
+ from .core.config import DatabaseProjectConfig, register_database, get_database_config, get_connection_string, \
2
+ get_manager_config, get_code_config, get_all_database_project_names, get_database_alias, get_all_database_projects_redacted
3
+
4
+ from .core.extended import BaseManager, BaseDTO
5
+ from .core.base import Model
6
+ from .core.registry import model_registry
7
+ from .core.fields import (CharField, EnumField, DateField, TextField, IntegerField, FloatField, BooleanField,
8
+ DateTimeField, UUIDField, JSONField, DecimalField, BigIntegerField, SmallIntegerField,
9
+ JSONBField, UUIDArrayField, JSONBArrayField, ForeignKey)
10
+
11
+ __all__ = ["DatabaseProjectConfig", "register_database", "get_database_config", "get_connection_string",
12
+ "get_manager_config", "get_code_config", "get_all_database_project_names", "get_default_code_config",
13
+ "BaseManager", "BaseDTO", "Model", "model_registry", "CharField", "EnumField", "DateField", "TextField",
14
+ "IntegerField", "FloatField", "BooleanField", "DateTimeField", "UUIDField", "JSONField", "DecimalField",
15
+ "BigIntegerField", "SmallIntegerField", "JSONBField", "UUIDArrayField", "JSONBArrayField", "ForeignKey", "get_database_alias",
16
+ "get_all_database_projects_redacted"]
File without changes
@@ -0,0 +1,69 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Dict, Any, List, Union
3
+ from types import TracebackType
4
+ from typing import Type, Optional
5
+
6
+
7
+ class BaseAdapter(ABC):
8
+ @abstractmethod
9
+ async def execute_query(self, query: Dict[str, Any]) -> List[Dict[str, Any]]:
10
+ pass
11
+
12
+ @abstractmethod
13
+ async def fetch(self, query: Dict[str, Any]) -> Optional[Dict[str, Any]]:
14
+ pass
15
+
16
+ @abstractmethod
17
+ async def fetch_by_id(self, model: Any, record_id: Union[str, int]) -> Optional[Dict[str, Any]]:
18
+ pass
19
+
20
+ @abstractmethod
21
+ async def count(self, query: Dict[str, Any]) -> int:
22
+ pass
23
+
24
+ @abstractmethod
25
+ async def exists(self, query: Dict[str, Any]) -> bool:
26
+ pass
27
+
28
+ @abstractmethod
29
+ async def insert(self, query: Dict[str, Any]) -> Dict[str, Any]:
30
+ pass
31
+
32
+ @abstractmethod
33
+ async def bulk_insert(self, query: Dict[str, Any]) -> List[Dict[str, Any]]:
34
+ pass
35
+
36
+ @abstractmethod
37
+ async def update(self, query: Dict[str, Any], data: Dict[str, Any]) -> int:
38
+ pass
39
+
40
+ @abstractmethod
41
+ async def bulk_update(self, query: Dict[str, Any]) -> int:
42
+ pass
43
+
44
+ @abstractmethod
45
+ async def delete(self, query: Dict[str, Any]) -> int:
46
+ pass
47
+
48
+ @abstractmethod
49
+ async def raw_sql(self, sql: str, params: List[Any] = None) -> Union[List[Dict[str, Any]], int]:
50
+ pass
51
+
52
+ @abstractmethod
53
+ async def transaction(self):
54
+ pass
55
+
56
+ @abstractmethod
57
+ async def close(self):
58
+ pass
59
+
60
+ async def __aenter__(self):
61
+ return self
62
+
63
+ async def __aexit__(
64
+ self,
65
+ exc_type: Optional[Type[BaseException]],
66
+ exc_val: Optional[BaseException],
67
+ exc_tb: Optional[TracebackType],
68
+ ):
69
+ await self.close()