Python operation MySQL Database

Source: Internet
Author: User
Tags mysql in

Environment

Win10,python3.6,pycharm,mysql57

Installation

MySQL installation, the cost of a bit of trouble, then install Pymysql:

Pip Install Pymysql

Then you can use python3.6 to operate MySQL, but to use MySQL in the pycharm, you need some steps, see http://www.jb51.net/article/112715.htm and http:// blog.csdn.net/tongxinzhazha/article/details/70257014, in short, is:

1. Find and install Databbase Navigator in the Pycharm setting-plugins

2. Download MySQL Jdbcmysql-connector-java and put it in any directory

3. Open the database plugin of pycharm, add a MySQL connection, fill in the host, database name (in advance database), username, login password, Then change the driver path to the path of file Mysql-connector-java-5.1.45-bin.jar in 2.

Using the command line to manipulate MySQL

cmd command Line window into D:\mysql57\soft\bin, first typed net start MySQL, make sure MySQL is started, and then typed Mysql-u root-p, Prompt for a password (forget to check with your girlfriend's chat history) and then go to MySQL interface.

Refer to big bro and this

Python operation MySQL

First of all

import MySQL

Then connect to the database

Connect = pymysql. Connect (      host='localhost',      Port=3306,      user='  root',      passwd=' password ',      db='  database name ',      charset='UTF8'   )

Reference http://blog.csdn.net/johline/article/details/69549131 and Insect master

Python operation MySQL database

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.