This tutorial introduce severval basic but fundamental operations of MySQL in Python environment so that you can manipulate your database directly in Python.
Python 2.7
MySQL database
Env: win10
-
Get your MySQL installed.
-Download MySQLYou can use the simplest way to install —— MySQL installer. Click it and download.
-Installingunpack the package and follow installation instructions. You can choose 'server Only' in thechoose a setup typeSection or customize your installation. -
Get your MySQL libaray installed in Python
Simply usepip install MySQLto install MySQL -
Configuration
- After installing the MySQL, you register your own account.
-(Optional,but recoommended)Initiate a configuration file named 'Config.ini' so as to get access to your database more quickly without typing account info everytime you'd like to access it. Details on this will be elaborated latter. -
Basic operations
Connect to the database: get connected to your database server. ONLY WHEN YOU HAVE ESTABLISHED A DATABASE.build database: create database or create new tables.insert data: insert new data to your established databasedb config: configurate your database inconfig.iniand use the simpler and reuseable way to log in.fetch with one: fetch items from your database