You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* create new abstraction for code generation.
create more clear documentation for each pynest project supported
change "orm_config" file name convention to "config"
add "setting.yml" file that contains metadata on the application
* create 4 different examples apps:
blank application
mongo based application
sync orm application (old versions of sqlalchemy)
async orm applications (support in async await)
* fix tests
* add PyYAML to dependencies
* fix integration_test.yaml
* fix integration_test.yaml
* add astor to dependencies
* fix pynest command
* fix pynest command
* fix settings suffix
* add black to dependencies
* The server is started in the background using &.
sleep 10 is used to wait for the server to start. You might need to adjust this time based on how quickly your server starts.
After the tests, kill $(jobs -p) is used to terminate the background server process. || true is added to ensure that the workflow continues even if no job is found (in case the server process exits for some reason before this step).
* add -f flag to the curl requests. fix the curl post request
* fix post request
* add sqlite integration test
* fix prefix
* use another port for the orm app
* fix issue - #28
* change the integration test trigger rule
* make --is_async a flag
make integration test run parallel
add explanation about the cli commands
* fix Error: No such option: --is_async Did you mean --is-async?
* fix curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused
* fix curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused
* fix curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused
* fix integration_test.yaml
* fix integration_test.yaml
* fix integration_test.yaml
* fix integration_test.yaml
* fix integration_test.yaml
* fix documantation
* update README.md
* remove pynest logo background
* remove pynest logo background
* remove pynest logo background
* update README.md
<em>PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS</em>
@@ -26,7 +26,7 @@ PyNest is designed to help structure your APIs in an intuitive, easy to understa
26
26
27
27
With PyNest, you can build scalable and maintainable APIs with ease. The framework supports dependency injection, type annotations, decorators, and code generation, making it easy to write clean and testable code.
28
28
29
-
This framework is not a direct port of NestJS to Python but rather a re-imagining of the framework specifically for Python developers, including data scientists, data analysts, and data engineers. It aims to assist them in building better and faster APIs for their data applications.
29
+
This framework is not a direct port of NestJS to Python but rather a re-imagining of the framework specifically for Python developers, including backend engineers and ML engineers. It aims to assist them in building better and faster APIs for their data applications.
30
30
31
31
## Getting Started
32
32
To get started with PyNest, you'll need to install it using pip:
@@ -44,17 +44,12 @@ this command will create a new project with the following structure:
44
44
45
45
```text
46
46
├── app.py
47
-
├── orm_config.py
48
47
├── main.py
48
+
├── requirements.txt
49
+
├── .gitignore
50
+
├── README.md
49
51
├── src
50
52
│ ├── __init__.py
51
-
│ ├── examples
52
-
│ │ ├── __init__.py
53
-
│ │ ├── examples_controller.py
54
-
│ │ ├── examples_service.py
55
-
│ │ ├── examples_model.py
56
-
│ ├── ├── examples_entity.py
57
-
│ ├── ├── examples_module.py
58
53
```
59
54
60
55
once you have created your app, get into the folder and run the following command:
@@ -101,24 +108,14 @@ AsyncOrmProvider is a key component in managing asynchronous database connection
101
108
### AsyncSession
102
109
AsyncSession from sqlalchemy.ext.asyncio is used for executing asynchronous database operations. It is essential for leveraging the full capabilities of SQLAlchemy 2.0 in an async environment.
103
110
104
-
## Implementing Async Features
105
-
### Creating Models
106
-
Define your models using SQLAlchemy's declarative base. For example, the Examples model:
107
-
108
-
### AsyncSession
109
-
110
-
AsyncSession, from sqlalchemy.ext.asyncio is used
111
-
for executing asynchronous database operations.It is essential for leveraging the full capabilities of SQLAlchemy 2.0 in
112
-
an async environment.
113
-
114
111
## Implementing Async Features
115
112
116
-
### Creating Models
113
+
### Creating Entities
117
114
118
115
Define your models using SQLAlchemy's declarative base. For example, the Examples model:
119
116
120
117
```python
121
-
fromorm_configimport config
118
+
fromconfigimport config
122
119
from sqlalchemy import Integer, String
123
120
from sqlalchemy.orm import Mapped, mapped_column
124
121
@@ -136,11 +133,11 @@ Implement services to handle business logic.
136
133
There are two ways of creating service.
137
134
138
135
1. In that way, the service does not init any parameter, and that each function that depends on the database is getting
139
-
the async session fron the controller
136
+
the async session from the controller
140
137
141
138
```python
142
-
fromsrc.examples.examples_model import Examples
143
-
fromsrc.examples.examples_entity import Examples as ExamplesEntity
139
+
from .examples_model import Examples
140
+
from .examples_entity import Examples as ExamplesEntity
144
141
from nest.core.decorators.database import async_db_request_handler
145
142
from sqlalchemy import select
146
143
from sqlalchemy.ext.asyncio import AsyncSession
@@ -168,9 +165,9 @@ class ExamplesService:
168
165
using the session that was init in the constructor
169
166
170
167
```python
171
-
fromsrc.examples.examples_model import Examples
172
-
fromsrc.examples.examples_entity import Examples as ExamplesEntity
173
-
fromorm_configimport config
168
+
from .examples_model import Examples
169
+
from .examples_entity import Examples as ExamplesEntity
170
+
fromconfigimport config
174
171
from nest.core.decorators.database import async_db_request_handler
175
172
from functools import lru_cache
176
173
from sqlalchemy import select, text
@@ -181,7 +178,7 @@ class ExamplesService:
181
178
182
179
def__init__(self):
183
180
self.orm_config = config
184
-
self.session =self.orm_config.get_self_db
181
+
self.session =self.orm_config.session
185
182
186
183
@async_db_request_handler
187
184
asyncdefadd_examples(self, examples: Examples):
@@ -206,18 +203,18 @@ logic.
206
203
207
204
Here we have also two ways of creating the controller.
208
205
209
-
1. In that way, the controller's functions are getting the async session from the orm_config
206
+
1. In that way, the controller's functions are getting the async session from the config
210
207
211
208
```python
212
209
from nest.core import Controller, Get, Post, Depends
0 commit comments