MySQL using notes

Source: Internet
Author: User

1, download, download version too much, do not know which is good, others introduced version

Go to the official website-click on the bottom downloads--> select MySQL on Windows (Installer & Tools)-->mysql installer--> Select

Windows (x86, 32-bit), MSI Installer 5.7.20 376.3M (mysql-installer-community-5.7.20.0.msi) My computer is WIN10 64 bit, also do not know why choose 32- Bit

2, installation, normal step by step click Install

3. Basic operation of MySQL database

ImportPymysqlImportPandas as PD#do the most basic first, and then slowly adjust the optimization in practice#First, connect the databaseCon=pymysql.connect (host='localhost', user='Root', password='1***', database=' World') Cursor=con.cursor ()#ii. Creating databases and Tables#Create a database#create_schema= "CREATE schema abc"#Cursor.execute (Create_schema)##创建表#create_table= ' CREATE TABLE ABC. Persons\# (\#id_p int not null,\#LastName varchar (255) Not null,\#FirstName varchar (255), \#Address varchar (255), \#City varchar (255) \#) '#Cursor.execute (create_table)#third, delete the table, delete the database#drop_table= "drop table Abc.persons"#Cursor.execute (drop_table)#drop_schema= ' drop schema abc '#Cursor.execute (Drop_schema)#Iv. Writing DataInsert_data="INSERT INTO ABC. Persons values (1, ' A ', ' B ', ' C ', ' d ')"Cursor.execute (insert_data)#Delete some data, if a row of data input error, can be deleted and then write#if the entire data is to be modified, you can delete the table, create a new table#1. Delete one row (multiple rows or columns can be looped)#drop_row= ' Delete from abc.persons where Id_p=1 '#Cursor.execute (Drop_row)#2. Delete a columndrop_column='ALTER TABLE abc.persons drop column City'  #ALTER TABLE ***.*** DROP column * *Cursor.execute (drop_column)#3. Add a column or columns of data#add_column= ' ALTER TABLE abc.persons add city varchar (255) '#Cursor.execute (add_column)Con.commit ()#Six, read the data#QueryStringquerystring='SELECT * from Sakila.actor'#reading data using Read_sqlData=pd.read_sql (querystring, con);Print(Data.head ())

MySQL using notes

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.