aio-libs / aio-libs/aiomysql

Better documentation on how connection/cursor work

未關閉
#871 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
docs enhancement
主要語言
Python
星號
1.9k
分支
272
PR 合併指標
30 天內沒有已合併 PR

描述

### 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

- [X] I agree to follow the aio-libs Code of Conduct

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。