summaryrefslogtreecommitdiff
path: root/examples/asyncio/async_orm.py
Commit message (Collapse)AuthorAgeFilesLines
* add AsyncAttrsMike Bayer2023-05-081-4/+11
| | | | | | | | | | Added a new helper mixin :class:`_asyncio.AsyncAttrs` that seeks to improve the use of lazy-loader and other expired or deferred ORM attributes with asyncio, providing a simple attribute accessor that provides an ``await`` interface to any ORM attribute, whether or not it needs to emit SQL. Change-Id: I1427b288dc28319c854372643066c491b9ee8dc0 References: #9731
* update asyncio examples and add notes about writeonlyMike Bayer2023-02-051-21/+20
| | | | Change-Id: I1233eb1a860b915fb265ec8bf177f1a0471cdbd1
* pep-484: asyncioMike Bayer2022-04-111-5/+2
| | | | | | | | | | | | | | | | | | | | | in this patch the asyncio/events.py module, which existed only to raise errors when trying to attach event listeners, is removed, as we were already coding an asyncio-specific workaround in upstream Pool / Session to raise this error, just moved the error out to the target and did the same thing for Engine. We also add an async_sessionmaker class. The initial rationale here is because sessionmaker() is hardcoded to Session subclasses, and there's not a way to get the use case of sessionmaker(class_=AsyncSession) to type correctly without changing the sessionmaker() symbol itself to be a function and not a class, which gets too complicated for what this is. Additionally, _SessionClassMethods has only three methods on it, one of which is not usable with asyncio (close_all()), the others not generally used from the session class. Change-Id: I064a5fa5d91cc8d5bbe9597437536e37b4e801fe
* Apply minor update to async_orm exampleGord Thompson2021-10-201-1/+2
| | | | | | | | | | | - Fixed import to avoid MovedIn20Warning. - Separated drop_all() and create_all() into separate context managers to avoid dropping and creating the same table within the same transaction. Apparently some databases (e.g., CockroachDB) don't allow that. Change-Id: Id26d7d719871a75ffb78c6af589658666802fb2f
* Document implicit IO points in ORMMike Bayer2021-02-071-1/+17
| | | | | | | | | | | | | | | I purposely didn't spend much documentation writing about implicit IO when I first pushed out the asyncio extension because I wanted to get a sense on what kinds of issues people had. Now we know and the answer is predictably "all of them". List out all the known implicit IO points and how to avoid them. Also rename the "adapting lazy loads" section, so that the title is less suggestive that this is a necessary technique. References: #5926 Change-Id: I3933b74bd37a5b06989531adbeade34347db679b
* upgrade to black 20.8b1Mike Bayer2020-09-281-1/+2
| | | | | | | It's better, the majority of these changes look more readable to me. also found some docstrings that had formatting / quoting issues. Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b
* Implement rudimentary asyncio support w/ asyncpgMike Bayer2020-08-131-0/+89
Using the approach introduced at https://gist.github.com/zzzeek/6287e28054d3baddc07fa21a7227904e We can now create asyncio endpoints that are then handled in "implicit IO" form within the majority of the Core internals. Then coroutines are re-exposed at the point at which we call into asyncpg methods. Patch includes: * asyncpg dialect * asyncio package * engine, result, ORM session classes * new test fixtures, tests * some work with pep-484 and a short plugin for the pyannotate package, which seems to have so-so results Change-Id: Idbcc0eff72c4cad572914acdd6f40ddb1aef1a7d Fixes: #3414