MySQL is a Relational Database Management System (RDBMS) whereas the structured Query Language (SQL) is the language used for handling the RDBMS using commands i.e Creating, Inserting, Updating and Deleting the data from the databases. SQL commands are case insensitive i.e CREATE and create signify the same command.
Follow the below-mentioned process for installing the dependencies for python MySQL
- Navigate to the python script directory using the command prompt.
- Execute the command
pip install mysql-connector
Python Mysql Connector Module Methods
- connect() :
This Function is used for extablishing connection with the MySQL server.
The following are the arguments that are used to initiate a connection.
- user: User name associated with the MySQL server used to authenticate the connection
- password: Password associated with the user name for authentication
- database: Data base in the MySQL for creating the Table
Cursor is the work space created in the system memory when the SQL command is executed.This memory is temporary and the cursor connection is bounded for the entire session/lifetime and the commands are executed
The execute function takes a SQL query as an argument and executes.A query is any SQL command which is used to create, insert, retrieve, update, delete etc.
The database is an organization of information structured into multiple tables. Databases are organized in such a way so that manipulating the data is easy i.e Creating, inserting, updating, and deleting etc.
SQL command for Creating Database :
CREATE DATABASE ;
Example: Consider the below example for creating a database in MySQL(Ex: college)
College Data base is created
- Table is a collection of data organized in the form of rows and columns. Table is present withint a database.
- Rows are also called tuples
- Columns are called the attributes of the table
SQL command for Creating Table :
CREATE TABLE ( column_name_1 column_Data_type, column_name_2 column_Data_type, : : column_name_n column_Data_type );
SQL Data types
Data types are used for defining the type of data that will be stored in the cell of the table.
Different Types of the Datatypes
- Unicode Character/String
Apart from the above-mentioned datatypes, there are other miscellaneous data types in MySQL that include datatypes of
Consider the below-mentioned python code for creating a table of the “student” which contains two Columns Name, Roll number in the database “college” previously created.
Student Table is Created in the Database
- Python MySQL - Insert into Table
- Python MySQL - Drop Table
- Python MySQL - Create Database
- Create MySQL Database Login Page in Python using Tkinter
- How to Create a Pivot Table in Python using Pandas?
- How to Create a Pivot table with multiple indexes from an excel sheet using Pandas in Python?
- Connect MySQL database using MySQL-Connector Python
- Create Table Using Tkinter
- MySQL-Connector-Python module in Python
- Python MySQL - Join
- Python MySQL - Where Clause
- Python MySQL - Update Query
- Python MySQL - Limit Clause
- Python MySQL - Delete Query
- Python MySQL - Select Query
- Python MySQL - Order By Clause
- How to install MySQL connector package in Python?
- Contingency Table in Python
- Convert CSV to HTML Table in Python
- Python | Convert an HTML table into excel
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.