aio-libs / aiomysql

aiomysql is a library for accessing a MySQL database from the asyncio
https://aiomysql.rtfd.io
MIT License
1.76k stars 257 forks source link

Any plans to support SQL prepared statements? #293

Open vlanse opened 6 years ago

vlanse commented 6 years ago

https://dev.mysql.com/doc/refman/5.6/en/sql-syntax-prepared-statements.html

Do you have any plans to support this? Could be useful to utilise MySQL server more efficient, e.g. do not parse SQL on server any time the same query with different parameters appears.

jettify commented 6 years ago

I think they should work in same way as stored procedure work: https://github.com/aio-libs/aiomysql/blob/274cfc067c827fa3837af39d475181cdaeae1fbc/examples/example_callproc.py#L5-L22

vlanse commented 6 years ago

@jettify sorry, just a little more context. I meant especially sqlalchemy case (e.g. when using sa connection) right now the execute code always substitutes values on client side

jettify commented 6 years ago

Does sqlalchemy support prepared statements?

vlanse commented 6 years ago

Well, looks like it's not about sqlalchemy which is responsible for building the queries. The sa compiled statement itself could be handled by connector in a special way - like "prepared" statement.

Nothing4You commented 2 years ago

considering that this library is based on PyMySQL this should be implemented in PyMySQL first and only then ported to aiomysql.

see https://github.com/PyMySQL/PyMySQL/issues/202