Create Table
Posted 2022-11-09 05:52:29
0
242
To create a MySQL table in Python, use the "CREATE TABLE" statement.
Make sure you define the name of the database when you create the connection.
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword", database="mydatabase" ) mycursor = mydb.cursor() mycursor.execute("CREATE TABLE customers (name VARCHAR(255), address VARCHAR(255))")
Check if Table Exists
You can check if a table exist by listing all tables in your database with the "SHOW TABLES" statement:
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword", database="mydatabase" ) mycursor = mydb.cursor() mycursor.execute("SHOW TABLES") for x in mycursor: print(x)
Search
Categories
- Information Technology
- Office Equipment and Supplies
- Cars and Trucks
- Persons
- Books and Authors
- Tutorials
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Games
- Gardening
- Health
- Home
- Literature
- Music
- Networking
- Other
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Read More
Canada E-house Market Challenges: Growth, Share, Value, Trends, and Analysis
"Executive Summary Canada E-house Market :
Canada E-house market is expected to gain...
Automotive Roof Bar Market Growth: Share, Value, Size, Scope, and Insights
"Executive Summary Automotive Roof Bar Market :
The global automotive roof bar...
Europe Ambulance Services Market Size & Outlook 2033
Ambulance services are emergency medical services that give those who are unwell or injured rapid...
Surgical Site Infection Control Market Expands with Emphasis on Hospital Safety and Hygiene
"Executive Summary Surgical Site Infection Control Market: Share, Size & Strategic...
軍用高速救助艇の世界市場規模:最新トレンド、成長要因、今後動向2025-2031
2025年7月25日、QYResearch株式会社(所在地:東京都中央区)は、「軍用高速救助艇―グローバル市場シェアとランキング、全体の売上と需要予測、2025~2031」の調査レポートを発行し...