Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio-compatible dialect #212

Open
cancan101 opened this issue Mar 24, 2022 · 2 comments
Open

asyncio-compatible dialect #212

cancan101 opened this issue Mar 24, 2022 · 2 comments

Comments

@cancan101
Copy link
Collaborator

cancan101 commented Mar 24, 2022

SQLAlchemy 1.4 now supports Python asyncio. In order to take advantage of this, the dialect must be "asyncio-compatible". It would be great to have a version of the base Dialect that can be used for this.

A discussion for what that entails: sqlalchemy/sqlalchemy#7854.

Currently the APSWDialect class subclasses SQLiteDialect, which is not async. There is a SQLiteDialect_aiosqlite that could potentially be used. The goal here is not necessarily to have async operations vis a vis sqlite but rather to allow async operations when connecting to the APIs.

This might be tricky as you would want this to be an async iterator:

def _convert(self, cursor: "apsw.Cursor") -> Iterator[Tuple[Any, ...]]:

and then likewise have the get_rows call be an async iterator:
self.data = (
tuple(row.get(name) for name in ["rowid", *column_names]) for row in rows
)

I filed this upstream though I am not 100% sure this is the right way to solve the ask: rogerbinns/apsw#325

@betodealmeida
Copy link
Owner

Oof, this sounds hard. I'm going to try to implement this in another dialect (https://github.com/DataJunction/datajunction/blob/main/src/datajunction/sql/sqlalchemy/dialect.py) first to understand better what it entails.

@betodealmeida betodealmeida self-assigned this Jul 25, 2022
@cancan101
Copy link
Collaborator Author

Yea this might be a pipe dream . Not sure it's possible in SQLite. Might be possible using postgres as engine with fdw

@betodealmeida betodealmeida removed their assignment Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants