Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

No project description provided

Project description

# 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


from sqlalchemy import MetaData, Integer, String, DateTime
from 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)


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

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

or (low-level):

objects = await MyEntity.objects \
.set_sql( \
.where([( == 'foo')]) \
.limit(10) \


record = await MyEntity.objects.insert(

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


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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aiosqlalchemy-miniorm, version 0.2.13
Filename, size File type Python version Upload date Hashes
Filename, size aiosqlalchemy_miniorm-0.2.13.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page