How to install MySQL connector in python?
RDBMS is an application software for creating and managing relational databases. It makes possible for us to create, read, update and delete data from a database.
MySQL is a popular RDBMS software which use a client server model.
MySQL, is an open source relational database management system. It is based on the structure query language (SQL), which is used for adding, removing, and modifying information in the database.
Installation of MySQL:-
- Open the command prompt
- Type the following command.
- pip install MySQL -python
- Successfully install MySQL database.
You can easily import MySQL in python and use it.
syntax:-
import MySQLdb
We can create a new table by importing mysql.connector.
syntax:-
import mysql.connector db_connection = mysql.connector.connect ( host="hostname", user="root", password="pin", database="name_of_database" )
We have some function which has some specific work:-
- cursor.execute()- This is used to execute SQL queries.
- cursor.close()- It is used to close the cursor object.
- connection.close()- It is used to close MySQL database after the work is done
In this way we can connect python with MySQL.
Subscribe
Login
Please login to comment
0 Discussion