Python reads MySQL database table data

Source: Internet
Author: User
  • Environment

Python 3.6, Window 64bit

  • Objective

Reads the target table data from the MySQL database and processes

  • Code
#-*-Coding:utf-8-*-import pandas as Pdimport pymysql## plus character set parameters to prevent Chinese garbled dbconn=pymysql.connect (    host= "**********",    database= "Kimbo",    user= "Kimbo_test",    password= "******",    port=3306,    charset= ' UTF8 ') # SQL statement sqlcmd= "Select Col_name,col_type,col_desc from Itf_datadic_dtl_d limit" #利用pandas module to import MySQL data a=pd.read_sql ( Sqlcmd,dbconn) #取前5行数据b =a.head () print (b) # read CSV data # pd.read_csv () # Read Excel Data #pd.read_excel () # Read TXT data #pd.read_table ( )

Results

  

Python reads MySQL database table data

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.