Create Database
Posté 2022-11-07 09:44:40
0
234
To create a database in MySQL, use the "CREATE DATABASE" statement:
Below is the example of Creating a MySQL Database in Python:
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) mycursor = mydb.cursor() mycursor.execute("CREATE DATABASE mydatabase")
If the above code was executed with no errors, It means your database has been successfully created.
Check if Database Exists
You can also check if a database exist before you create a database by listing all databases in your system by using the "SHOW DATABASES" statement. Below is the example:
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) mycursor = mydb.cursor() mycursor.execute("SHOW DATABASES") for x in mycursor: print(x)
Rechercher
Catégories
- Information Technology
- Office Equipment and Supplies
- Cars and Trucks
- Persons
- Books and Authors
- Tutorials
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Jeux
- Gardening
- Health
- Domicile
- Literature
- Music
- Networking
- Autre
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Lire la suite
世界環境エネルギー応用触媒産業調査:市場シェア、需要分析、投資報告2025
2025年6月12日、YH Research株式会社(本社:東京都中央区)は、調査レポート「グローバル環境エネルギー応用触媒市場のトップ企業ランキングと市場シェア...
Global Travel Vaccine Market Size, Share, Trends & Forecast to (2024-2032) | UnivDatos
According to the UnivDatos, the expansion of the travel vaccine market into emerging markets...
Securing Your UK Skilled Worker Visa with Immigration Solicitors4me, Expert Immigration Lawyer in Manchester
The UK Skilled Worker Visa is a vital pathway for professionals worldwide seeking to...
POE 2’s Most Addictive Spell Build? Try the Blood Mage Spark Engine-ELD.gg
Path of Exile 2 has brought with it a fresh wave of creativity, power creep, and sheer chaos, and...
© 2025 Omaada - A global social and professionals networking platform
French
