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
Больше
ナノファイバーベースの濾材業界の投資判断:市場戦略と競争環境の展望2025-2031
YH Research株式会社(本社:東京都中央区)は、「グローバルナノファイバーベースの濾材のトップ会社の市場シェアおよびランキング...
ZeroMOUSE Preis im Test: Innovation ohne hohen Preis
In der heutigen digitalen Welt ist eine leistungsstarke Maus mehr als nur ein praktisches...
Smile Brighter with Tailored Private Dental Solutions
In a fast-paced world, a confident smile goes beyond appearance; it reflects self-assurance and...
Trapstar Italia Speaks Street – Fashion Fluency in Urban Dialect
There’s a rhythm to the street. A sound, a style, a swagger. Not everyone hears...
© 2025 Omaada - A global social and professionals networking platform
Russian
