Reason
Recently, I am tossing a small item to capture the online page, parse it, and put the result in the database. If you understand the advantages of Python in this regard, you can choose it. Because I have a server installed with mysql, you can use it naturally. Many problems have been encountered during the database operation. Let's record them here.
Call mysql in python
After Baidu, you can use MySQLdb to perform database operations, view the documentation, and learn that python provides a mysql that directly implements the mysql C language API. MySQLdb is an encapsulation of it on a higher layer, so it is more convenient to use. We can use mysql, but a better way is to use MySQLdb.
Problems encountered during installation
On this page, refer.
- Pass
python setup.py build
The installation prompt is displayed.No module named setuptools
Solution: Install
1 |
sudo apt-get install python-setuptools
|
- If you run the command again, mysql_config not found may still fail.
In this case, install mysqld-dev.
12 |
sudo apt-get install libmysqld-dev
|