Skip to main content
# Asynchronous SQLAlchemy Object Relational Mapper.

This is an ORM for accessing SQLAlchemy using asyncio. Working on top of SQLAlchemy Core.

It presents a method of associating user-defined Python classes with database tables, and instances of those classes (objects) with rows in their corresponding tables.

## Usage

Initialization:

from sqlalchemy import MetaData, Integer, String, DateTime
from aiopg.sa import create_engine
from aiosqlalchemy_miniorm import RowModel, RowModelDeclarativeMeta, BaseModelManager

metadata = MetaData()
BaseModel = declarative_base(metadata=metadata, cls=RowModel, metaclass=RowModelDeclarativeMeta)

async def setup():
metadata.bind = await create_engine(**database_settings)

class MyEntityManager(BaseModelManager):
async def get_with_products(self):
return await self.get_items(where_list=[(MyEntity.c.num_products > 0)])

class MyEntity(BaseModel):
__tablename__ = 'my_entity'
__model_manager_class__ = MyEntityManager

id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)
num_products = Column(Integer)
created_at = Column(DateTime(), server_default=text('now()'), nullable=False)

Query:

objects = await MyEntity.objects.get_instances(
where_list=[(MyEntity.c.name == 'foo')],
order_by=['name', '-num_products']
)

num_objects = await MyEntity.objects.count(
where_list=[(MyEntity.c.name == 'foo'), (MyEntity.c.num_products > 3)]
)

or (low-level):

objects = await MyEntity.objects \
.set_sql(MyEntity.table.select()) \
.where([(MyEntity.c.name == 'foo')]) \
.limit(10) \
.fetchall()

Management:

record = await MyEntity.objects.insert(
name='bar',
num_products=0,
)

await record.update(name='baz')
await record.delete()


Transactions:

async with MyEntity.objects.transaction() as my_entity_objects:
await my_entity_objects.insert(name='bar', num_products=0)
await my_entity_objects.delete([(MyEntity.c.name == 'foo')])

Metadata

Release files for aiosqlalchemy-miniorm 0.2.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiosqlalchemy-miniorm 0.2.13
File Size Uploaded Provenance Actions
aiosqlalchemy_miniorm-0.2.13.tar.gz 4.7 kB Without provenance Details for aiosqlalchemy_miniorm-0.2.13.tar.gz

Release files / aiosqlalchemy_miniorm-0.2.13.tar.gz

Download URL aiosqlalchemy_miniorm-0.2.13.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ba7ea5c95b80dd3d09f566c40524ec85c04c50c0786462fd8d6a5658a579707a
BLAKE2b-256 checksum
How to use checksums
ed6d6124f41776fca48233fd35f6d55758a301fc9833dbb3b170258d83dfa5b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for aiosqlalchemy-miniorm 0.2.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.13 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page