前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住给大家分享一下。点击跳转到网站:https://www.captainai.net/dongkelun
前言
总结记录Python 连接 MYSQL
代码
1 | from sqlalchemy import create_engine |
结果 :1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 id isdeal
0 1 0
1 2 0
2 3 0
3 4 0
4 5 0
5 6 0
6 7 0
7 8 0
8 9 0
9 10 0
id isdeal
0 6 0
1 7 0
2 8 0
3 9 0
4 10 0
异常
执行上面代码时可能会抛出下面异常1
ModuleNotFoundError: No module named 'MySQLdb'
解决1
2
3
4
5$ pip install mysqlclient
Collecting mysqlclient
Downloading https://files.pythonhosted.org/packages/5d/b3/a753b836eab49c865651eb2bc7203d070c58e5f22b33015b48fa6112bd7a/mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl (262kB)
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6
然后再执行上面代码就可以了