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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
async support #339
Comments
@prryplatypus there is no plan for it. Mainly for 2 reasons:
If you would like to explore what the effort would be to add async support to this project I would be more than willing to listen, even help you during that discovery phase. It could be as easy as adding a new model or query builder. Or maybe as easy as inheriting from In other words, I'm not sure what the effort would be to do something like this. Also I'm not sure what the effort would be to maintain something like this. Maybe its better off inside this package or maybe its better off as an adapter package. Either way I'm personally unfamiliar with how async ORM's are working and really have a lot more questions than answers about this issue lol. If you are very familiar with how it works I'd love to discuss more with you but this is not something I want to explore on my own and in my own time right now |
Understandable! I'm not very familiar with all of the intrinsics of asynchronous code, but it is something I do use pretty much every day. In general most of the SQL wrappers out there are pretty much a drop-in replacement of the non-async versions, except for having to prepend the async def execute(self, query, *args, **kwargs):
async with self.pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute(query, args)
await conn.commit() That being said, if/when I have some free time (don't even know what free time is at this point) I will try messing around with this project and see if I manage to do anything with it! Many thanks for your reply :) |
Sounds great. Anybody reading this in the future, I am open to the idea but this idea needs to be explored more by someone who is more familiar with async ORM's than I am, or someone who can answer some open questions I have. This is not a simple feature request so I will need to write a feature product specification document for this feature which takes a lot of time to discover and create. @girardinsamuel before we close this issue for good do you have any thoughts? |
Hello there ! |
I was just curious does Masonite support Async and found this thread. There is a package from the creators of Django Rest Framework called databases that gives asyncio support for a range of databases. import asyncio
from databases import Database
from masoniteorm.query import QueryBuilder
from config.database import DB
database = Database('sqlite+aiosqlite:///masonite.db')
async def main():
await database.connect()
# Create a table.
# NOTE: Can be generated using Masonite Model & Migrations.
query = """CREATE TABLE IF NOT EXISTS highscores (id INTEGER PRIMARY KEY, name VARCHAR(100), score INTEGER)"""
await database.execute(query=query)
# Run a database query.
query = QueryBuilder().table("highscores").to_sql()
print(query)
rows = await database.fetch_all(query=query)
print('High Scores:', rows)
asyncio.run(main()) Not sure about down sides... |
Hi there! 馃憢
Just thought I'd ask if adding async support is planned for this project anytime in the future. There seems to be a wide range of ORM packages for sync projects, but those which aren't sync are usually left to interact with the "raw" DB directly by using libraries like asyncpg, aiopg or aiomysql.
It would be great to have an Eloquent-like ORM which supported asynchronous code, so that projects following the asynchronous model (or libraries like Sanic or discord.py) could also make use of a neat abstraction layer that packages like this one provide.
Thank you very much in advance!
The text was updated successfully, but these errors were encountered: