Create Table
Сообщение 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)
Поиск
Категории
- Information Technology
- Office Equipment and Supplies
- Cars and Trucks
- Persons
- Books and Authors
- Tutorials
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Игры
- Gardening
- Health
- Главная
- Literature
- Music
- Networking
- Другое
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Больше
High-Speed Data and Miniaturization Drive Demand for LCP Rectangular Connectors
"Executive Summary Rectangular Liquid Crystal Polymer (LCP) Connectors Market :...
Autonomous Surgical Robotics Market Trends, Insights and Future Outlook
"Executive Summary Autonomous Surgical Robotics Market :
Data Bridge Market...
Toronto’s Trusted Choice for Sink Surface Renewal
When it comes to enhancing the look and function of your kitchen or bathroom, one of the most...
North America Marine Low-Speed Diesel Engine Market Thrives on U.S. Trade
North America Marine Low-Speed Diesel Engine Market to be...
Resume Writing Services
Top Resume Writing Services & Online Resume Builder | Key Resumes
Looking for Resume Writing...
© 2025 Omaada - A global social and professionals networking platform
Russian
