First, download the kernel (at least in CentOS, in/usr/bin/, find it like this: ls/usr/bin/| grep ldquo; mysql rdquo ;) then add the path of mysql_config to the site in the MySQLdb folder. cfg
First Download: http://sourceforge.net/projects/mysql-python/Decompress the package and find the location of mysql_config (at least in CentOS, in/usr/bin/, so that you can find the location: ls/usr/bin/| grep "mysql ")
Then, add the path of mysql_config to t
Install MYSQLDB in ubuntu, and record Ubuntu in pymssql
BitsCN.com
Install MYSQLDB on ubuntu and record pymssql
1. install MYSQLDB
9 wget http://jaist.dl.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz
Tar zxvf MySQL-python-1.2.4b4.tar.gz
Cd MySQL-python-1.2.4b4/
sudo apt-get install libmysqlclient-devsudo apt-get
When using a third-party python mysql package to execute SQL statements containing UTF8 characters, the following errors may occur:'Ascii 'codec can't encode character ...... 'Or'Latin-1' codec can't encode character ...... '
In fact, you only need to note the encode before inserting:
Python statement:
01# Coding = UTF-802Import MySQLdb03Cc = 'ours'04Conn = MySQLdb. connect (05Host = "localhost ",06User = "root ",07Passwd = "root ",08Port = 3306,09Db
No module named 'mysqldb' error handling when to_ SQL operation is performed using pandas of tushare, tushareto_ SQL
Write it first. When you use tushare to obtain financial data, there is no need to use Python 3.
Py2 functions are no different, but py3 has many places that need to be modified to run successfully, causing a waste of time.
Next, let's go to the question. This problem has plagued me for one afternoon and one night. Write it down to r
[Python] install Django in ubuntu, connect MySQLdb to the database [XMAPP], and djangomysqldb
By default, python2.7 and 3.4 are installed in Ubuntu. Here, Django is installed through pip (tool for installing and managing Python packages ).
Install pip before installing pip
apt-get install python-pip
apt-get install python3-pip
The first is the python 2.x Installation tool.
After installation, pip installs Django online.
pip install Django==1.8
Mysqldb usage in python and pythonmysqldb usage
1. Introduce the MySQLdb Library
Import MySQLdb2. Establish a connection with the databaseConn = MySQLdb. connect (host = "localhost", user = "root", passwd = "The connect method is used to establish a connection with the database, receive several parameters, and return the connection object.
Common parameters in
LinuxNon-root usersPythonAndMySQLdbRecord:
Install the required software package: python-2.6.tar.bz2133 mysql-python-1.2.3c1.tarw.setuptools-0.6c11.tar.gz.
Before installation:
1. Define the python installation directory:
PYTHON_DIR = /home/$USER/local/python
2. Define the installation directory:
INSTALL_DIR = /home/$USER/install
First, check the python version of the Local Machine. If the corresponding version is installed, skip step 1;
python Python 2.6 (r26:66714, Jul 21 2010, 11:47:32) [GCC
Python
# Ln-s prefix/Python-2.5.2/python./Python // prefix unzip the python directory for you
# Python
# Python
Python 2.5.2 (#1, Dec 11 2006, 11:38:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "help", "copyright", "credits" or "License" for more information.
>>>
Or modify the PATH variable Vim/etc/bashrc to add export Path = $ python_dir/bin :$ {path}
OK! Solve the problem!
4. Install mysqldb:
Tar-C $ install_dir-
My Ubuntu is installed by default python2.7 and 3.4, where Django is installed by Pip (tool for installing and managing Python packages)Do not install PIP first install PIP toolApt-get Install Python-pip Apt-get Install Python3-pipThe first is the Python 2.x version of the installation tool if you want Django on Python3, use the following.Pip installs Django online after installation Pip Install django==1.8 After the equals sign is followed by the Django version number here my is 1.8,
First step: Connect
Import MySQLdb #首先需要引入mysqldb即Python module to connect to MySQL.Conn=mysqldb.connect (host= "localhost", user= "root", passwd= "") #此处等价于缺省值时即conn =mysqldb.connect ()cur = conn.cursor () #创建游标, used to send SQL instructions so you can send SQL instructions to MySQL with cursor cur.
Step Two: Operation
1. Create a database
Cur.execute (' Create Database Adams ') again under the MySQL
Special, previously on the Linux server, install MYSQLDB, in fact, as long as:
Install MySQLdb:Pip Install Mysql-pythonOK, now because to install in the MAC system, the results of various errors ah ... I don't answer the error, there are 2 kinds of errors:
1. Environmenterror:mysql_config not Found
2, _mysql.c:44:10:fatal error: ' my_config.h ' File not found
MAC OS Installation mysqldb is really a vari
Tags: BSP error init err import Import Direct Python3 addIn Python2, use pip install Mysql-python to install the library connected to MySQL, using the import mysqldbIn Python3, change the connection library, changed to the Pymysql Library, use pip install Pymysql to install, directly import can useIn Django, however, the database is connected using the MYSQLDB library, which in cooperation with PYTHON3 will report the following error:'
On the WINDOWS10 system, Python2.7 installation MYSQLDB error: Microsoft Visual C + + 9.0 is required ....According to the error prompt to solve the useless .....According to the online information, the Final Solution:Download MYSQL_PYTHON-1.2.5-CP27-NONE-WIN_AMD64.WHL (https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python, then pip Install XXXX.WHL installation)D:\01 software\Python相关软件>pip install MySQL_python-1.2.5-cp27-none-win_amd64.whlYou are
Label:When using MySQLdb or SQLAlchemy, you will find that the fields in the table Integer are converted by default for the long type. This behavior is actually done by the DB API, which is all MySQLdb's fault (assuming you're using this API). This is because the range of MySQL unsigned int has exceeded int the upper limit and forced use may cause overflow. But the upper limit of int is above 10 trillion, generally used as ID, there is a lot of space
get the corresponding HTML, then congratulate you, you climbed the site to do anti-crawler. This time add headers can solve this problem very well. such as headers={ ' User-agent ': ' This place is looking for the URLs you want to crawl, F12+f5 ' } Filtering unwanted information requires regular expressions, and the most basic re.compile ("HTML") is to prevent escaping and improve compilation efficiency. Come over the unwanted information can be used Re.findall (req,html), so you can filter the
Tags: obj arc org-fpic rom lib Fat sdn UIBy default, the MYSQLDB package is not installed, do not believe? You'll believe it if you see something like the following code.-bash-3.2#/usr/local/python2.7.3/bin/python get_cnblogs_news.pyTraceback (most recent):File "get_cnblogs_news.py", line 9, Import MySQLdbImporterror:no module named MySQLdbThen we had to install the MYSQLDB package. Installation is actually
Tags: http ar io os using for on file dataSince the development of the Python Web scanner requires support in python2.7.5 and the need to mysqldb this library, here is a record to avoid the learning cost of changing to a new environment. First, install MySQL1, yum install mysql-server mysql-devel MySQL (must be able to network)2. Start MySQL:/etc/init.d/mysqld start3. Log in as root account MySQL (initial password is empty): Mysql-u root4. Set the roo
Tags: pythonThe mysqldb of Windows to build a Python environmentFirst, install the Setuptoolsdownload ez_setup.py See attachment, Official DownloadsD:d:\>ez_setup.pySecond, installation MySQLdbDirect download exe direct installation, code compilation can also, unless you have a lot of time.https://pypi.python.org/pypi/MySQL-python/1.2.4Third, test moduleC:\users\serven>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5, 20:40:30) [MSC v.1500-bit (AMD64)
:\myproject\testhzq\1\site-packages\sqlalchemy\engine\__init__.py ", line 338, in Create_engine return Strategy.create (*args, **kwargs) Fil E "D:\myproject\testhzq\1\site-packages\sqlalchemy\engine\strategies.py", line +, in Create Dbapi = Dialect_cls.dbapi (**dbapi_args) File "D:\myproject\testhzq\1\site-packages\sqlalchemy\connectors\mysqldb.py", line Dbapi return __import__ (' MySQLdb ') Importerror:no module named MySQLdbDiscover the need to ins
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.