-
Notifications
You must be signed in to change notification settings - Fork 22
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
async pug #44
Comments
For async you have a few options. I'm currently using encode/databases. It's been working great except for a few bugs that have been merged to master but not released yet. The difference is that you can't have you sql queries in separate .sql files, which I think is one of the strengths of pugsql. For that, you can check aiosql. It shares a lot with pugsql, apart from async, another difference is that it parses the queries using regex rather than relying on sqlalchemy. SQLAlchemy got support for asyncio in 1.4: https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html So maybe pugsql will support async when it updates? I don't know. |
Thanks for all the data! I'm thinking now, maybe do something just with queries = load_queries("resources/sql")
await database.execute(query=queries.find_user, user_id=42)
# or await database.execute_many(query=queries.find_user, user_id=42) I'd get the highlight/lint from a |
That's actually an interesting way to do it. I don't know if you plan to load the queries manually or use aiosql. With aiosql you can access the ray sql string: https://nackjicholson.github.io/aiosql/advanced-topics/#accessing-prepared-sql-as-a-string So one option may be having your queries in a .sql file to get highlight/linting. Load the queries with aiosql and then execute them with encode/databases. This is a field I'm currently exploring myself, so I don't have a lot of experience. I am now porting an app from encode/databases to aiosql just to see how that would look like. One thing to take into account is that by using only aiosql you can remove the sqlalchemy dependency. If you are constrained by how big your app can be, that is something to consider (but with Python I'd say that's not the main challenge). |
I did not actually try this, but i hope this works for you: |
Hello people! I'm starting a small project with starlette and I'd like to try pugsql, I found it super interesting, it's great project! But starlette is async and I'd like to benefit from it.
I was wondering if there's a way to make pugsql async. I've been reading the source of pug and encode/databases, but still not sure where to begin.
Any recommendations, idea?
Thanks
The text was updated successfully, but these errors were encountered: