aiomysql is a library for accessing a MySQL database from the asyncio (PEP-3156/tulip) framework. It depends and reuses most parts of PyMySQL . aiomysql tries to be like awesome aiopg library and preserve same api, look and feel.
Questions tagged [aio-mysql]
27 questions
7
votes
1 answer
asyncio improperly warns about streams objects are garbage collected; call "stream.close()" explicitly
I was implementing asynchronous MySQL query execution using python3.8's inbuilt asyncio package and an installed aiomysql package. Even though I have closed properly all the open cursor and connection, an error message keep on appearing on my…

Akhil Mathew
- 1,571
- 3
- 34
- 69
6
votes
1 answer
Do I need to keep track of the asyncio event loop, or can I just call asyncio.get_event_loop when it is needed?
I am writing a REST API using aiohttp.
Some of the coroutines need to call the database using the aiomysql library. The documentation for aiomysql has the following example:
import asyncio
import aiomysql
loop = asyncio.get_event_loop()
async def…

ostrokach
- 17,993
- 11
- 78
- 90
5
votes
0 answers
readexactly() called while another coroutine is already waiting for incoming data
Use pool connection - aiomysql
my code looks like this:
# POOL CONNECTION
# create pool connection
async def create_pool():
print("Creating pool connection...")
global pool
pool = await aiomysql.create_pool(
host=DB_HOST,
…

timmy
- 65
- 5
4
votes
1 answer
How should I set up aiomysql pool cache?
When I use mysql_pool from aiomysql to update a piece of data, the first time is same as the second time.
class Test(object):
async def _pool(self):
self.pool = await aiomysql.create_ç(**mysql_options)
async def get_one(self, sql,…

Alex
- 68
- 4
3
votes
0 answers
aiomysql row locking when using multiple asyncio programs
I have a mysql table on aws mysql and as such my python asyncio program which is using aiomysql - https://github.com/aio-libs/aiomysql connects to a remote mysql database.
My table shop has the following fields: id, names, product_id,…

Gandalf
- 1
- 29
- 94
- 165
2
votes
1 answer
DB connection issue with encode/databases library
I have an error
pymysql.err.InternalError: Packet sequence number wrong - got 0 expected 1
after leaving my application idle (0 requests to DB) for few hours.
I thought, databases module creates connection pool (it does) and recreates connections…

Aleksandr Valentirov
- 21
- 6
2
votes
2 answers
discord py - how can i boost the speed of my code up?
i have a problem. I want to make a task for my giveaway-bot for checking if a giveaway ended. So I created a task for doing it and it runs many lines of code and everything is working. But I noticed that my code is pretty slow. Can anyone help me…
user16635088
2
votes
1 answer
Class variable is NoneType even though attribute was defined
I have a class that looks like this:
class DatabaseTest:
def __init__(self):
self.headers = {
"host": os.environ["HOST"],
"username": os.environ["USERNAME"],
"password": os.environ["PASSWORD"]
…

Atomization
- 45
- 5
2
votes
1 answer
aiomysql select data problem: not updated
version:
Python 3.6.9
aiomysql: 0.0.20
aiohttp: 3.6.2
problem:
where mysql table data deleted or inserted, query data is not updated for hours, unless web_app restart.
codes using aiomysql pool:
# initial
pool = await…

whi
- 2,685
- 6
- 33
- 40
1
vote
1 answer
python3.9 and mysql async - Why i'm getting "Task was destroyed but it is pending!"?
i have a weird problem since i'm using an async mysql driver with Python3.9. I often get this error:
Task was destroyed but it is pending!
task:

Razzer
- 492
- 1
- 4
- 29
1
vote
0 answers
Trying to use asyncio sqlalchemy it just freeze
I trying to make async database request using sqlalachemy like described in example :
https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html#synopsis-orm under title : Preventing Implicit IO when Using AsyncSession.
As i understood from code…

John Doe
- 21
- 5
1
vote
1 answer
fastapi + aiomysql connection pool stuck after 10 calls
Why aiomysql connection pool stuck after N calls? (N is the maxsize number of connection. Tried the default N=10 and N=3)
I thought the acquired connections are automatically closed on exit with async with.
Here's the minimal script to…

luthfianto
- 1,746
- 3
- 22
- 37
1
vote
0 answers
ContextManagers instead of Instances in aiomysql
Python 3.8, aiomysql
I have a code:
import aiomysql
class AsyncSQL:
def __init__(self, loop):
self.pool = aiomysql.create_pool(host="localhost", user="root", password="root",
db="chatdb",…

MhDelt
- 21
- 3
1
vote
1 answer
aioMySQL not connecting with python
I know this is somewhat of a duplicate, but I've looked in every nook and cranny of the internet and I can't seem to find the solution to this. Basically, I'm trying to connect to a mySQL database via aioMySQL. My Script is far too long to put in,…

BlackCoffee
- 159
- 1
- 10
1
vote
0 answers
Troubles using async library : aiomysql (python - bot)
I'm trying to transform my standard database functions into aiomysql async functions (for a bot) but I don't really understand how does the async functions work...
Here's my actual code that I want to transform :
def connection(Database):
conn =…

aut0wash
- 45
- 8