Python Database API ( Application Program Interface ) is the Database interface for the standard Python. This standard is adhered to by most Python Database interfaces. There are various Database servers supported by Python Database such as MySQL, GadFly, mSQL, PostgreSQL, Microsoft SQL Server 2000, Informix, Interbase, Oracle, Sybase etc. To connect with MySQL database server from Python, we need to import the
Below is a program to connect with MySQL database
The above program illustrates the connection with the MySQL database
geeks in which host-name is
localhost, the username is
user and password is
After connecting with the database in MySQL we can select queries from the tables in it.
In order to select particular attribute columns from a table, we write the attribute names.
SELECT attr1, attr2 FROM table_name
- In order to select all the attribute columns from a table, we use the asterisk ‘*’ symbol.
SELECT * FROM table_name
Example 1: Let’s consider the table looks like this –
Below is a program to select a query from the table in the database.
Example 2: Let us look at another example for selecting queries in a table.
- Python MySQL - Delete Query
- Python MySQL - Update Query
- Connect MySQL database using MySQL-Connector Python
- Python MySQL - Where Clause
- Python MySQL - Join
- MySQL-Connector-Python module in Python
- Python MySQL - Drop Table
- Python MySQL - Limit Clause
- Python MySQL - Create Database
- Python: MySQL Create Table
- Python MySQL - Insert into Table
- Python MySQL - Order By Clause
- How to install MySQL connector package in Python?
- Python MongoDB - Query
- Python | Pandas Series.select()
- Python | Select random value from a list
- numpy.select() function | Python
- Select any row from a Dataframe in Pandas | Python
- Python MongoDB - insert_one Query
- Python MongoDB - Limit Query
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.