I am trying to build a tool that one step of it is connecting to MySQL database.

Just I am so confused about ODBC. If I want to build a cross platform connector by python, should I use python connector or ODBC connector?

I know JDBC, but ODBC stands for Open Database Connectivity. It looks like more compatible.

Could anyone help me clarify that? Thank you very much.

有帮助吗?

解决方案

Python has its own DB API v2.0 abstraction layer to connect to databases (it serves the same purpose of ODBC or JDBC but for Python). You should use one of the DB API v2.0 compliant oursql, MySQLdb or PyMySQL packages to connect to MySQL from Python. All these packages are cross platform and will work on Linux, Windows and MacOS X. oursql, and MySQLdb are wrappers for libmysql and PyMySQL is a pure Python implementation.

Note that there are DB API v2.0 implementations (like pyodbc) that provide ODBC connectivity, so conceptually you could connect to MySQL via ODBC, but this would have inferior performance than the above mentioned "native" drivers because of the extra abstraction layers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top