Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frameworks/Python/aiohttp/aiohttp-pg-raw.dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM python:3.8
FROM python:3.13

ADD ./ /aiohttp

WORKDIR aiohttp

RUN pip3 install cython==0.29.23 && \
RUN pip3 install cython==3.0.11 && \
pip3 install -r /aiohttp/requirements.txt

ENV CONNECTION=RAW
Expand Down
4 changes: 2 additions & 2 deletions frameworks/Python/aiohttp/aiohttp.dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM python:3.8
FROM python:3.13

ADD ./ /aiohttp

WORKDIR aiohttp

RUN pip3 install cython==0.29.23 && \
RUN pip3 install cython==3.0.11 && \
pip3 install -r /aiohttp/requirements.txt

WORKDIR /aiohttp
Expand Down
11 changes: 6 additions & 5 deletions frameworks/Python/aiohttp/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import asyncpg
from aiohttp import web
from sqlalchemy.engine.url import URL
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine

from .views import (
json,
Expand Down Expand Up @@ -48,15 +47,17 @@ async def db_ctx(app: web.Application):
print(f'connection pool: min size: {min_size}, max size: {max_size}, orm: {CONNECTION_ORM}')
if CONNECTION_ORM:
dsn = pg_dsn('asyncpg')
engine = create_async_engine(dsn, future=True, pool_size=max_size)
app['db_session'] = sessionmaker(engine, class_=AsyncSession)
engine = create_async_engine(dsn, pool_size=max_size)
app['db_session'] = async_sessionmaker(engine)
else:
dsn = pg_dsn()
app['pg'] = await asyncpg.create_pool(dsn=dsn, min_size=min_size, max_size=max_size, loop=app.loop)

yield

if not CONNECTION_ORM:
if CONNECTION_ORM:
await app['db_session'].dispose()
else:
await app['pg'].close()


Expand Down
14 changes: 7 additions & 7 deletions frameworks/Python/aiohttp/app/models.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import DeclarativeBase, Mapped

Base = declarative_base()
class Base(DeclarativeBase):
"""Base for models."""


class World(Base):
__tablename__ = 'world'
id = Column(Integer, primary_key=True)
randomnumber = Column(Integer)
id: Mapped[int] = mapped_column(primary_key=True)
randomnumber: Mapped[int]

sa_worlds = World.__table__


class Fortune(Base):
__tablename__ = 'fortune'
id = Column(Integer, primary_key=True)
message = Column(String)
id: Mapped[int] = mapped_column(primary_key=True)
message: Mapped[str]

sa_fortunes = Fortune.__table__
15 changes: 7 additions & 8 deletions frameworks/Python/aiohttp/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
aiohttp==3.10.2
asyncpg==0.25.0
cchardet==2.1.7
gunicorn==20.1
aiohttp==3.10.10
asyncpg==0.30.0
gunicorn==23.0.0
jinja2==3.1.4
psycopg2==2.9.2
SQLAlchemy==1.4.29
ujson==5.4.0
uvloop==0.16
psycopg2==3.2.3
SQLAlchemy==2.0.36
ujson==5.10.0
uvloop==0.21.0
Loading