简体   繁体   中英

What is the fastest/most performant SQL driver for Python?

我知道PyMySQLDb,这是访问MySql的最薄/最轻的方式吗?

The fastest is SQLAlchemy.

"Say what!?"

Well, a nice ORM, and I like SQLAlchemy, you will get your code finished much faster . If your code then runs 0.2 seconds slower isn't really gonna make any noticeable difference. :)

Now if you get performance problems, then you can look into improving the code. But choosing the access module after who in theory is "fastest" is premature optimization.

The lightest possible way is to use ctypes and directly call into the MySQL API, of course, without using any translation layers. Now, that's ugly and will make your life miserable unless you also write C, so yes, the MySQLDb extension is the standard and most performant way to use MySQL while still using the Python Database API. Almost anything else will be built on top of that or one of its predecessors.

Of course, the connection layer is rarely where all of the database speed problems come from. That's mostly from misusing the API you have or building a bad database or queries.

MySQLDb更快,而SQLAlchemy使代码更加用户友好-:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM