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

Better documentation on how connection/cursor work #871

Open
1 task done
ZisIsNotZis opened this issue Nov 11, 2022 · 0 comments
Open
1 task done

Better documentation on how connection/cursor work #871

ZisIsNotZis opened this issue Nov 11, 2022 · 0 comments

Comments

@ZisIsNotZis
Copy link

Is your feature request related to a problem?

I'm using aiohttp.web and aiomysql. Before reading the source code, I had no idea weather I should:

  • Keep a global cursor and use it
  • Keep a global connection and derive a cursor for each request
  • Keep a global connection pool and acquire one for each request

Since the traditional "blocking" model uses the third method, and the simple examples given does not use connection pool, I thought method 1 or 2 are also fine.

But after I read the source code, I found that connection is essentially a state machine, and cursor is a “fake” proxy to it. Reusing the same connection at the same time might cause problems. (Correct me if I'm wrong)

Describe the solution you'd like

A better documentation is deserved, especially in README.md, that highlights the importance of using connection pool in concurrent use case.

Describe alternatives you've considered

I'm not sure weather mysql supports pipelining in the same connection (like http pipelining). If it does, maybe cursors can be implemented that way to support concurrent connection reuse?

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants