mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
Merge pull request #34 from grillazz/onboard-alembic😉
python 3.10 improvements
This commit is contained in:
commit
51409707e3
4
.github/workflows/build-and-test.yml
vendored
4
.github/workflows/build-and-test.yml
vendored
@ -8,12 +8,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.7", "3.8", "3.9", "3.10"]
|
python-version: ["3.9", "3.10"]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
services:
|
services:
|
||||||
sqldb:
|
sqldb:
|
||||||
image: postgres:13
|
image: postgres:14
|
||||||
env:
|
env:
|
||||||
POSTGRES_USER: user
|
POSTGRES_USER: user
|
||||||
POSTGRES_PASSWORD: secret
|
POSTGRES_PASSWORD: secret
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# pull official base image
|
# pull official base image
|
||||||
FROM postgres:13-alpine
|
FROM postgres:14-alpine
|
||||||
|
|
||||||
# run create.sql on init
|
# run create.sql on init
|
||||||
ADD create.sql /docker-entrypoint-initdb.d
|
ADD create.sql /docker-entrypoint-initdb.d
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
from typing import List
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.exc import SQLAlchemyError
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
@ -15,7 +13,7 @@ logger = get_logger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/add_many", status_code=status.HTTP_201_CREATED)
|
@router.post("/add_many", status_code=status.HTTP_201_CREATED)
|
||||||
async def create_multi_stuff(payload: List[StuffSchema], db_session: AsyncSession = Depends(get_db)):
|
async def create_multi_stuff(payload: list[StuffSchema], db_session: AsyncSession = Depends(get_db)):
|
||||||
try:
|
try:
|
||||||
stuff_instances = [Stuff(name=stuf.name, description=stuf.description) for stuf in payload]
|
stuff_instances = [Stuff(name=stuf.name, description=stuf.description) for stuf in payload]
|
||||||
db_session.add_all(stuff_instances)
|
db_session.add_all(stuff_instances)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from the_app.models.nonsense import Nonsense # noqa
|
from the_app.models.nonsense import Nonsense # noqa
|
||||||
from the_app.models.stuff import Stuff # noqa
|
|
||||||
from the_app.models.shakespeare import Character # noqa
|
from the_app.models.shakespeare import Character # noqa
|
||||||
|
from the_app.models.stuff import Stuff # noqa
|
||||||
|
Loading…
x
Reference in New Issue
Block a user