Python MySQL Connector

Python Database

We can choose the any database as per our best and convenient of our application.

Python Database API supports a wide range of database servers such as −

  • GadFly
  • mSQL
  • MySQL
  • PostgreSQL
  • Microsoft SQL Server 2000
  • Informix
  • Interbase
  • Oracle
  • Sybase

Python Database Interfaces and APIs. You must download a separate DB API module for each database you need to access.

Following the steps given bellow to connect a python application to our database.

  • Import mysql.connector module
  • Create the connection object.
  • Execute the query

Lets Create The Connection With Database

The time of creating connections between the MySql database and the python application, there is a method called connect() method is used.

connect() methods is accessed from mysql.connector module is used.

To make the connection we must pass the database detailts such as HostName, Username, and database password in the method call.

Hence, the method will returns the connection object or status.


 <mysql.connector.connection.MySQLConnection object ar 0x016645F0>

Create DataBase

In the next tutorial we will create the Database and Tabel.