![]() |
VOOZH | about |
In Python, a MySQL database can be created using the CREATE DATABASE statement. The mysql.connector module is used to connect Python programs with the MySQL server and execute database creation queries.
CREATE DATABASE database_name;
Example 1: In this example, the code connects to the MySQL server and creates a database named company.
Output
Database created successfully.
Explanation:
Example 2: Here, the code creates a database named school only if it does not already exist in the MySQL server.
Output
Database checked/created successfully.
Explanation: