File tree Expand file tree Collapse file tree 8 files changed +17
-23
lines changed
Expand file tree Collapse file tree 8 files changed +17
-23
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ SQL_TEST_DB=testdb
66SQL_HOST = db
77SQL_USER = user
88SQL_PASS = secret
9+ SQL_URL = postgresql+asyncpg://${ SQL_USER } :${ SQL_PASS } @${ SQL_HOST } /${ SQL_DB }
910
1011ALGORITHM = HS256
1112ACCESS_TOKEN_EXPIRE_MINUTES = 30
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ async def update_nonsense(
3636 db_session : AsyncSession = Depends (get_db ),
3737):
3838 nonsense = await Nonsense .find (db_session , name )
39- await nonsense .update (db_session , ** payload .dict ())
39+ await nonsense .update (db_session , ** payload .model_dump ())
4040 return nonsense
4141
4242
@@ -45,6 +45,6 @@ async def merge_nonsense(
4545 payload : NonsenseSchema ,
4646 db_session : AsyncSession = Depends (get_db ),
4747):
48- nonsense = Nonsense (** payload .dict ())
48+ nonsense = Nonsense (** payload .model_dump ())
4949 await nonsense .save_or_update (db_session )
5050 return nonsense
Original file line number Diff line number Diff line change 11from typing import Annotated
22
33from fastapi import APIRouter , Depends , Query
4- from pydantic import Required
54from sqlalchemy .ext .asyncio import AsyncSession
65
76from app .database import get_db
1413 "/" ,
1514)
1615async def find_paragraph (
17- character : Annotated [str , Query (description = "Character name" )] = Required ,
16+ character : Annotated [str , Query (description = "Character name" )],
1817 db_session : AsyncSession = Depends (get_db ),
1918):
2019 return await Paragraph .find (db_session = db_session , character = character )
Original file line number Diff line number Diff line change @@ -54,5 +54,5 @@ async def update_stuff(
5454 db_session : AsyncSession = Depends (get_db ),
5555):
5656 stuff = await Stuff .find (db_session , name )
57- await stuff .update (db_session , ** payload .dict ())
57+ await stuff .update (db_session , ** payload .model_dump ())
5858 return stuff
Original file line number Diff line number Diff line change 11import os
22from functools import lru_cache
33
4- from pydantic import BaseSettings , PostgresDsn
4+ from pydantic import PostgresDsn
5+ from pydantic_settings import BaseSettings
56
67
78class Settings (BaseSettings ):
8- asyncpg_url : PostgresDsn = PostgresDsn .build (
9- scheme = "postgresql+asyncpg" ,
10- user = os .getenv ("SQL_USER" ),
11- password = os .getenv ("POSTGRES_PASSWORD" ),
12- host = os .getenv ("SQL_HOST" ),
13- port = "5432" ,
14- path = f"/{ os .getenv ('SQL_DB' ) or '' } " ,
15- )
9+ asyncpg_url : PostgresDsn = os .getenv ("SQL_URL" )
1610
1711
1812@lru_cache
Original file line number Diff line number Diff line change 1010logger = AppLogger .__call__ ().get_logger ()
1111
1212engine = create_async_engine (
13- global_settings .asyncpg_url ,
13+ global_settings .asyncpg_url . unicode_string () ,
1414 future = True ,
1515 echo = True ,
1616)
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ class NonsenseSchema(BaseModel):
1414 )
1515
1616 class Config :
17- orm_mode = True
18- schema_extra = {
17+ from_attributes = True
18+ json_schema_extra = {
1919 "example" : {
2020 "name" : "Name for Some Nonsense" ,
2121 "description" : "Some Nonsense Description" ,
@@ -38,8 +38,8 @@ class NonsenseResponse(BaseModel):
3838 )
3939
4040 class Config :
41- orm_mode = True
42- schema_extra = {
41+ from_attributes = True
42+ json_schema_extra = {
4343 "example" : {
4444 "config_id" : "3fa85f64-5717-4562-b3fc-2c963f66afa6" ,
4545 "name" : "Name for Some Nonsense" ,
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ class StuffSchema(BaseModel):
1414 )
1515
1616 class Config :
17- orm_mode = True
18- schema_extra = {
17+ from_attributes = True
18+ json_schema_extra = {
1919 "example" : {
2020 "name" : "Name for Some Stuff" ,
2121 "description" : "Some Stuff Description" ,
@@ -38,8 +38,8 @@ class StuffResponse(BaseModel):
3838 )
3939
4040 class Config :
41- orm_mode = True
42- schema_extra = {
41+ from_attributes = True
42+ json_schema_extra = {
4343 "example" : {
4444 "config_id" : "3fa85f64-5717-4562-b3fc-2c963f66afa6" ,
4545 "name" : "Name for Some Stuff" ,
You can’t perform that action at this time.
0 commit comments