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

Asynchronous version of read_database #20339

Open
alkment opened this issue Dec 17, 2024 · 0 comments
Open

Asynchronous version of read_database #20339

alkment opened this issue Dec 17, 2024 · 0 comments
Labels
enhancement New feature or an improvement of an existing feature

Comments

@alkment
Copy link

alkment commented Dec 17, 2024

Description

While it is possible to pass an asynchronous connection to pl.read_database, the action performed will be blocking. It would be great if we could actually async reads. That way a DB or multiple DBs could work on multiple queries at the same time.

Here is an example of what I mean:

import asyncio
from sqlalchemy.ext.asyncio import create_async_engine

async_engine = create_async_engine("sqlite+aiosqlite:///test.db")

async def main():
      t1=asyncio.create_task(pl.read_database_async(
          query="SELECT * FROM test_data_1", 
          connection=async_engine,
      ) )
      t2=asyncio.create_task(pl.read_database_async(
          query="SELECT * FROM test_data_2", 
          connection=async_engine,
      ) )
      df1=await t1
      df2=await t2
      return (df1,df2)

df1,df2=asyncio.run(main())
@alkment alkment added the enhancement New feature or an improvement of an existing feature label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant