Usage Prerequisites: The Windows environment is configured with Anaconda 3, where the Python version is 3.6.2. The default installation is pandas.
MySQL version: Download mysql 5.7.17 version, all the way next installation is complete.
Objective: To store the pandas Dataframe data in the database.
Problems encountered:
from Import = create_engine ('mysql://user:[email protected]/stocka?charset=utf8')
Return:
Traceback (most recent): File"<ipython-input-3-ccda39a1056f>", Line 1,inch<module>engine= Create_engine ('Mysql://reaver21:[email Protected]/stocka?charset=utf8') File"C:\Anaconda3\lib\site-packages\sqlalchemy\engine\__init__.py", line 387,inchCreate_enginereturnStrategy.create (*args, * *Kwargs) File"C:\Anaconda3\lib\site-packages\sqlalchemy\engine\strategies.py", Line 80,inchCreate Dbapi= DIALECT_CLS.DBAPI (* *Dbapi_args) File"C:\Anaconda3\lib\site-packages\sqlalchemy\dialects\mysql\mysqldb.py", line 110,inchDbapireturn __import__('MySQLdb') Modulenotfounderror:no module named'MySQLdb'
Search, should be mysqldb to python3.* support problem.
Install the Pymysql, and execute before creating the engine:
Import pymysql pymysql.install_as_mysqldb ()
Then the engine is created OK.
Thanks http://blog.csdn.net/haoaiqian/article/details/72652089
Learning MySQL (i)