Skip to content

Commit

Permalink
Merge branch 'release/0.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ri-gilfanov committed Jun 15, 2021
2 parents 60c4b7d + f409042 commit 2cb99f4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 26 deletions.
23 changes: 17 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ aiohttp-sqlalchemy
:target: https://aiohttp-sqlalchemy.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://badge.fury.io/py/aiohttp-sqlalchemy.svg
:target: https://pypi.org/project/aiohttp-sqlalchemy/
:alt: Package version

.. image:: https://img.shields.io/badge/Python-3.7%20%7C%203.8%20%7C%203.9-blue
:target: https://pypi.org/project/aiohttp-sqlalchemy/
:alt: Python versions supported

.. image:: https://img.shields.io/pypi/dm/aiohttp-sqlalchemy
:target: https://pypistats.org/packages/aiohttp-sqlalchemy
:alt: Downloads count

.. image:: https://travis-ci.com/ri-gilfanov/aiohttp-sqlalchemy.svg?branch=master
:target: https://travis-ci.com/ri-gilfanov/aiohttp-sqlalchemy
:alt: Build status

.. image:: https://coveralls.io/repos/github/ri-gilfanov/aiohttp-sqlalchemy/badge.svg?branch=master
:target: https://coveralls.io/github/ri-gilfanov/aiohttp-sqlalchemy?branch=master
:alt: Test coverage

SQLAlchemy 1.4 / 2.0 support for aiohttp.

Expand All @@ -25,6 +32,7 @@ The library provides the next features:
* initializing asynchronous sessions through a middlewares;
* initializing asynchronous sessions through a decorators;
* simple access to one asynchronous session by default key;
* preventing attributes from being expired after commit by default;
* support for different types of request handlers.


Expand Down Expand Up @@ -64,7 +72,7 @@ Copy and paste this code in a file and run:
class MyModel(Base):
__tablename__ = 'my_table'
id = sa.Column(sa.Integer, primary_key=True)
pk = sa.Column(sa.Integer, primary_key=True)
timestamp = sa.Column(sa.DateTime(), default=datetime.now)
Expand All @@ -77,15 +85,18 @@ Copy and paste this code in a file and run:
async with db_session.begin():
db_session.add_all([MyModel()])
result = await db_session.execute(sa.select(MyModel))
data = {record.id: record.timestamp.isoformat()
for record in result.scalars()}
return web.json_response(data)
items = result.scalars().all()
data = {}
for item in items:
data[item.pk] = item.timestamp.isoformat()
app = web.Application()
return web.json_response(data)
aiohttp_sqlalchemy.setup(app, [sa_bind('sqlite+aiosqlite:///')])
app = web.Application()
binding = sa_bind('sqlite+aiosqlite:///')
aiohttp_sqlalchemy.setup(app, [binding])
app.add_routes([web.get('/', main)])
if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion aiohttp_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TSABinding = Tuple[TSessionFactory, str, bool]


__version__ = '0.13.0'
__version__ = '0.13.1'

__all__ = ['DuplicateAppKeyError', 'DuplicateRequestKeyError',
'SAAbstractView', 'SABaseView', 'sa_bind', 'sa_decorator',
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Ruslan Ilyasovich Gilfanov'

# The full version, including alpha/beta/rc tags
release = '0.13.0'
release = '0.13.1'


# -- General configuration ---------------------------------------------------
Expand Down
23 changes: 17 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ Overview
:target: https://aiohttp-sqlalchemy.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://badge.fury.io/py/aiohttp-sqlalchemy.svg
:target: https://pypi.org/project/aiohttp-sqlalchemy/
:alt: Package version

.. image:: https://img.shields.io/badge/Python-3.7%20%7C%203.8%20%7C%203.9-blue
:target: https://pypi.org/project/aiohttp-sqlalchemy/
:alt: Python versions supported

.. image:: https://img.shields.io/pypi/dm/aiohttp-sqlalchemy
:target: https://pypistats.org/packages/aiohttp-sqlalchemy
:alt: Downloads count

.. image:: https://travis-ci.com/ri-gilfanov/aiohttp-sqlalchemy.svg?branch=master
:target: https://travis-ci.com/ri-gilfanov/aiohttp-sqlalchemy
:alt: Build status

.. image:: https://coveralls.io/repos/github/ri-gilfanov/aiohttp-sqlalchemy/badge.svg?branch=master
:target: https://coveralls.io/github/ri-gilfanov/aiohttp-sqlalchemy?branch=master
:alt: Test coverage

SQLAlchemy 1.4 / 2.0 support for aiohttp.

Expand All @@ -41,6 +48,7 @@ The library provides the next features:
* initializing asynchronous sessions through a middlewares;
* initializing asynchronous sessions through a decorators;
* simple access to one asynchronous session by default key;
* preventing attributes from being expired after commit by default;
* support for different types of request handlers.


Expand Down Expand Up @@ -75,7 +83,7 @@ Copy and paste this code in a file and run:
class MyModel(Base):
__tablename__ = 'my_table'
id = sa.Column(sa.Integer, primary_key=True)
pk = sa.Column(sa.Integer, primary_key=True)
timestamp = sa.Column(sa.DateTime(), default=datetime.now)
Expand All @@ -88,15 +96,18 @@ Copy and paste this code in a file and run:
async with db_session.begin():
db_session.add_all([MyModel()])
result = await db_session.execute(sa.select(MyModel))
data = {record.id: record.timestamp.isoformat()
for record in result.scalars()}
return web.json_response(data)
items = result.scalars().all()
data = {}
for item in items:
data[item.pk] = item.timestamp.isoformat()
app = web.Application()
return web.json_response(data)
aiohttp_sqlalchemy.setup(app, [sa_bind('sqlite+aiosqlite:///')])
app = web.Application()
binding = sa_bind('sqlite+aiosqlite:///')
aiohttp_sqlalchemy.setup(app, [binding])
app.add_routes([web.get('/', main)])
if __name__ == '__main__':
Expand Down
23 changes: 13 additions & 10 deletions examples/single_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
Base: 'Any' = orm.declarative_base(metadata=metadata)


class Request(Base):
__tablename__ = 'requests'
id = sa.Column(sa.Integer, primary_key=True)
class MyModel(Base):
__tablename__ = 'my_table'
pk = sa.Column(sa.Integer, primary_key=True)
timestamp = sa.Column(sa.DateTime(), default=datetime.now)


Expand All @@ -28,17 +28,20 @@ async def main(request):
await connection.run_sync(Base.metadata.create_all)

async with db_session.begin():
db_session.add_all([Request()])
result = await db_session.execute(sa.select(Request))
data = {record.id: record.timestamp.isoformat()
for record in result.scalars()}
return web.json_response(data)
db_session.add_all([MyModel()])
result = await db_session.execute(sa.select(MyModel))
items = result.scalars().all()

data = {}
for item in items:
data[item.pk] = item.timestamp.isoformat()

app = web.Application()
return web.json_response(data)

aiohttp_sqlalchemy.setup(app, [sa_bind('sqlite+aiosqlite:///')])

app = web.Application()
binding = sa_bind('sqlite+aiosqlite:///')
aiohttp_sqlalchemy.setup(app, [binding])
app.add_routes([web.get('/', main)])

if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aiohttp-sqlalchemy"
version = "0.13.0"
version = "0.13.1"
description = "SQLAlchemy 1.4 / 2.0 support for aiohttp."
authors = [
"Ruslan Ilyasovich Gilfanov <ri.gilfanov@yandex.ru>",
Expand All @@ -12,7 +12,6 @@ classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP",
]
Expand Down

0 comments on commit 2cb99f4

Please sign in to comment.