Create Database
Postado 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)
Pesquisar
Categorias
- Information Technology
- Office Equipment and Supplies
- Cars and Trucks
- Persons
- Books and Authors
- Tutorials
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Jogos
- Gardening
- Health
- Início
- Literature
- Music
- Networking
- Outro
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Leia Mais
5G基地局 セラミックフィルター業界分析レポート2025-2031:市場規模、産業調査、最新動向、成長機会
2025年6月17日に、QYResearch株式会社(所在地:東京都中央区)は、「5G基地局...
Orphan Drugs Market Research Report: Growth, Share, Value, Trends, and Insights
The worldwide "Orphan Drugs Market" 2025 Research Report presents a professional and complete...
触媒グレードの三酸化アンチモン業界分析レポート2025-2031:市場規模、産業調査、最新動向、成長機会
2025年6月19日に、QYResearch株式会社(所在地:東京都中央区)は、「触媒グレードの三酸化アンチモン―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調...
8 Frequently Replaced Honda Acty Parts and Why They Matter
The Honda Acty Kei truck is one of those small but mighty vehicles that’s earned a loyal...
メタサーフェス光学製品市場の産業チェーン分析:供給、コスト構造、価格変動2025
QYResearch株式会社(所在地:東京都中央区)は、最新の調査資料「メタサーフェス光学製品―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」を2025年5月15日...
© 2025 Omaada - A global social and professionals networking platform
Portuguese
