Manual installation of mysqldb with [Pip Easy_install]

Source: Internet
Author: User

MySQLdb Download:

http://sourceforge.net/projects/mysql-python/

https://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/

http://mysql-python.sourceforge.net/

Setuptools Tool Installation:

1.wget--no-check-certificate https://bootstrap.pypa.io/ez_setup.py //download:



Generated files: Easy_install,setuptools-23.1.0-py2.7.egg

Installing Easy_install Script To/usr/local/bin
Installing easy_install-2.7 Script To/usr/local/bin

Installed/usr/local/lib/python2.7/site-packages/setuptools-23.1.0-py2.7.egg//Record results

[email protected] ~]# which Easy_install
/usr/local/bin/easy_install


[[email protected] mysql-python-1.2.3] #


[[email protected] site-packages]#llTotal Dosage 772drwxr-xr-x root root 4096 June 28 03:58DJANGODRWXR-xr-x 2 root root 4096 June 03:58 django-1.9.7.dist-Info-rw-r--r--1 root root 291 June 04:04 easy-INSTALL.PTHDRWXR-xr-x 3 root root 4096 June 28 03:39MySQLdb-rw-r--r--1 root root 2352 June 28 03:39_mysql_exceptions.py-rw-r--r--1 root root 4303 June 28 03:39_mysql_exceptions.pyc-rw-r--r--1 root root 105453 June 04:51 mysql_python-1.2.3-py2.7-linux-X86_64.EGGDRWXR-xr-x 2 root root 4096 June 03:39 mysql_python-1.2.5-py2.7.egg-Info-rwxr-xr-x 1 root root 148389 June 28 03:39_MYSQL.SODRWXR-xr-x 4 root root 4096 June 03:33 pip-1.5.4-py2.7. Egg-rw-r--r--1 root root 119 Mar 20 17:49README-rw-r--r--1 root root 472857 June 03:06 setuptools-23.1.0-py2.7. Egg-rw-r--r--1 root root 28 03:06Setuptools.pth[[email protected] site-packages]#pwd/usr/local/lib/python2.7/site-packages
Pip, how to use Easy_installinstallation using Easy_install installation: $ wget-Q http://peak.telecommunity.com/dist/ez_setup.py$ python./ez_setup.py using: $ easy_install packagename#Mounting Kit$ easy_install-u PackageName#Update Kit$ easy_install-m PackageName#Uninstall Kit$ Easy_install--showhelp#Display Description

install using PIP Installation: $ easy_install-U setuptools#Update Setuptools version (important), Pip depends on Setuptools$ easy_install pip using: $ pip Install PackageName#Mounting Kit$ pip install-u PackageName#Update Kit$ pip Uninstall PackageName#Uninstall Kit$ pip Search PackageName#Search Suite$ pip Help#Display Description

#-*-encoding:gb2312-*-ImportOS, sys, stringImportMySQLdb#connecting to a databaseTry: Conn= MySQLdb.connect (host='localhost', user='Root', passwd='xxxx', db='test1')exceptException, E:Printe sys.exit ()#get the Cursor object to manipulatecursor=conn.cursor ()#Create a tablesql ="CREATE table if not exists test1 (name varchar (+) primary key, age int (4))"cursor.execute (SQL)#Inserting Datasql ="INSERT into Test1 (name, age) VALUES ('%s ',%d)"% ("Zhaowei", 23)Try: Cursor.execute (SQL)exceptException, E:Printe-SQL="INSERT into Test1 (name, age) VALUES ('%s ',%d)"% ("Zhang San"21st)Try: Cursor.execute (SQL)exceptException, E:Printe#insert more than oneSQL="INSERT into Test1 (name, age) values (%s,%s)"Val= (("John Doe", 24), ("Harry", 25), ("Hong Lu", 26))Try: Cursor.executemany (SQL, Val)exceptException, E:Printe#Querying out Datasql ="SELECT * from Test1"cursor.execute (SQL) AllData=Cursor.fetchall ()#If there is data returned, the loop output, AllData is a two-dimensional listifAllData: forRecinchAllData:PrintRec[0], rec[1] Cursor.close () conn.close ()

Manually installing MYSQLDB with [pip Easy_install]

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.