Python3 mysqlclient-1.3.6 (aka PyMySQL)?

I am still very much learning python and all sorts of ways to use third party modules. I installed https://pypi.python.org/pypi/mysqlclient which Python 3 and MySQL recommended here

I'm sure I installed the package correctly

D:\install\python modules>python -m pip install mysqlclient-1.3.6-cp34-none-win_amd64.whl
Unpacking d:\install\python modules\mysqlclient-1.3.6-cp34-none-win_amd64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient
Cleaning up...

      

strange when i try to import mysqlclient module i get below

D:\install\python modules>python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysqlclient
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'mysqlclient'

      

I checked the homepage https://github.com/PyMySQL/mysqlclient-python and I couldn't find examples on how to use this module. I am very confused, did I just miss the boat here?

+17


source to share


1 answer


The PyMySQL project includes a user manual . Not easy to find this manual (no obvious links) and add to the confusion, the module name doesn't match the package name. To use it, you need:

import MySQLdb

      

The module MySQLdb

implements PEP 249 - Python Database API Specification for Database Access. By using this API, Python code should be more portable across different relational database management systems.



It is not recommended to use a module _mysql

(which is also included in this package). It is not portable and works at a lower level of abstraction (MySQL C API implementation).

Here are two tutorials that you might find useful. I used them with the original MySQLdb package in Python 2, but the API is the same (as defined by PEP-249). They both contain practical examples of database access (reading and writing data) and I found them better for getting started with the API than the official documentation.

+30


source







All Articles