move notes to development.md
This commit is contained in:
parent
e488da4ada
commit
cb1533ca6e
2 changed files with 44 additions and 43 deletions
43
api/NOTES.md
43
api/NOTES.md
|
|
@ -1,43 +0,0 @@
|
|||
#### autogenerated api frontend
|
||||
|
||||
API can autogenerate a frontend that documents, and allows to play
|
||||
with, in a limited way, its interface. Make sure you have the
|
||||
following variables inside the current `.env`:
|
||||
|
||||
```
|
||||
docs_url=/docs
|
||||
root_path=''
|
||||
```
|
||||
|
||||
If the `.env` that is in-use is based on `env.default` then it is
|
||||
already the case. Start, or restart the http server, then go to
|
||||
`https://127.0.0.1:8000/docs`. That is autogenerated documentation
|
||||
based on pydantic schema, fastapi routes, and docstrings :wink:.
|
||||
|
||||
Happy experiments, and then documentation!
|
||||
|
||||
#### psycopg3 API
|
||||
|
||||
I mis-remember the psycopg v2 vs. v3 API.
|
||||
|
||||
For the record, the expected psycopg3's async api looks like the
|
||||
following pseudo code:
|
||||
|
||||
```python
|
||||
async with app.state.postgresql.connection() as cnx:
|
||||
async with cnx.transaction():
|
||||
row = await cnx.execute("SELECT EXISTS(SELECT 1 FROM public.tenants)")
|
||||
row = await row.fetchone()
|
||||
return row["exists"]
|
||||
```
|
||||
|
||||
Mind the following:
|
||||
|
||||
- Where `app.state.postgresql` is the postgresql connection pooler.
|
||||
- Wrap explicit transaction with `async with cnx.transaction():
|
||||
foobar()`
|
||||
- Most of the time the transaction object is not used;
|
||||
- Do execute await operation against `cnx`;
|
||||
- `await cnx.execute` returns a cursor object;
|
||||
- Do the `await cursor.fetchqux...` calls against the object return by
|
||||
a call to execute.
|
||||
|
|
@ -28,3 +28,47 @@ cd openreplay-dev/openreplay/scripts/helmcharts
|
|||
# bash local_deploy.sh help
|
||||
bash local_deploy.sh api
|
||||
```
|
||||
|
||||
### autogenerated api frontend
|
||||
|
||||
API can autogenerate a frontend that documents, and allows to play
|
||||
with, in a limited way, its interface. Make sure you have the
|
||||
following variables inside the current `.env`:
|
||||
|
||||
```
|
||||
docs_url=/docs
|
||||
root_path=''
|
||||
```
|
||||
|
||||
If the `.env` that is in-use is based on `env.default` then it is
|
||||
already the case. Start, or restart the http server, then go to
|
||||
`https://127.0.0.1:8000/docs`. That is autogenerated documentation
|
||||
based on pydantic schema, fastapi routes, and docstrings :wink:.
|
||||
|
||||
Happy experiments, and then documentation!
|
||||
|
||||
### psycopg3 API
|
||||
|
||||
I mis-remember the psycopg v2 vs. v3 API.
|
||||
|
||||
For the record, the expected psycopg3's async api looks like the
|
||||
following pseudo code:
|
||||
|
||||
```python
|
||||
async with app.state.postgresql.connection() as cnx:
|
||||
async with cnx.transaction():
|
||||
row = await cnx.execute("SELECT EXISTS(SELECT 1 FROM public.tenants)")
|
||||
row = await row.fetchone()
|
||||
return row["exists"]
|
||||
```
|
||||
|
||||
Mind the following:
|
||||
|
||||
- Where `app.state.postgresql` is the postgresql connection pooler.
|
||||
- Wrap explicit transaction with `async with cnx.transaction():
|
||||
foobar()`
|
||||
- Most of the time the transaction object is not used;
|
||||
- Do execute await operation against `cnx`;
|
||||
- `await cnx.execute` returns a cursor object;
|
||||
- Do the `await cursor.fetchqux...` calls against the object return by
|
||||
a call to execute.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue