
Добавил:
KaFaka
t.me
Инфо для ГУАП студентов от меня: https://kafaka.notion.site/99e6d9b70ca74f7baef3daea17839e5a
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:4 курс 1 семестр / Лабораторные / Python / LR1_1
.py import mysql.connector
# Connect to the database
cnx = mysql.connector.connect(
host='127.0.0.1',
user='root',
password='admin',
database='airport'
)
# Create a cursor object
cursor = cnx.cursor()
# Execute the query
query = 'SELECT * FROM passangers'
cursor.execute(query)
# Fetch all the results
results = cursor.fetchall()
# Output the results as a table
for row in results:
print(row)
# Close the cursor and connection
cursor.close()
cnx.close()
# Connect to the database
cnx = mysql.connector.connect(
host='127.0.0.1',
user='root',
password='admin',
database='airport'
)
# Create a cursor object
cursor = cnx.cursor()
# Execute the query
query = 'SELECT * FROM passangers'
cursor.execute(query)
# Fetch all the results
results = cursor.fetchall()
# Output the results as a table
for row in results:
print(row)
# Close the cursor and connection
cursor.close()
cnx.close()