aio-libs / aio-libs/aiomysql

How to correctly escape values should be better documented

Aperta
#320 0 commenti 7 reazioni 0 assegnatari Vedi su GitHub
docs
Lingua principale
Python
Stelle
1.9k
Fork
272
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hello

I was trying to assist someone using aiomysql for the first time. I myself use postgre and asyncpg, so I was relying on the documentation while helping them.

But the examples in the documentation use hard-coded queries or weird ways to escape, something a regular user would never do. Also the use of variables is too heavy. Examples should be clear, every argument of execute should be self evident, I think having the need to look at an additional variables while reading the documentation is unnecessary.

Examples:
* First SELECT in asyncpg docs: ``row = await conn.fetchrow('SELECT * FROM users WHERE name = $1', 'Bob')``. Clearly uses escaping, no weird variables.
* First SELECT in aiomysql docs: ``await cur.execute("SELECT Host,User FROM user")``. Doesn't escape anything
* First escaping SELECT in aiomysql docs: No select query is escaping python types...
* First escaping INSERT in aiomysql docs: ``await cur.executemany("INSERT INTO music_style (id, name) values (%s,%s)", data)``. Uses variable data that I would have to look up what it is...

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.