-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Failure: test-side #288
Comments
To resolve the import mysql.connector
import time
import sys
from mysql.connector import Error
def create_connection(host_name, user_name, user_password):
connection = None
try:
connection = mysql.connector.connect(
host=host_name,
user=user_name,
passwd=user_password
)
print("Connection to MySQL server successful")
except Error as e:
print(f"The error '{e}' occurred")
return connection
def create_database(connection, database_name):
if connection is None:
print("No connection available to create the database.")
return
cursor = connection.cursor()
try:
cursor.execute(f"CREATE DATABASE {database_name}")
print(f"Database '{database_name}' created successfully")
except Error as e:
print(f"The error '{e}' occurred")
def execute_query_in_database(connection, database_name, query, count):
if connection is None:
print("No connection available to execute the query.")
return
try:
cursor = connection.cursor()
cursor.execute(f"USE {database_name}")
for i in range(count):
cursor.execute(query)
if query.strip().upper().startswith('SELECT'):
result = cursor.fetchall()
for row in result:
print(row)
else:
connection.commit()
print("Query executed successfully")
time.sleep(0.5)
except Error as e:
print(f"The error '{e}' occurred")
count = int(sys.argv[1])
connection = create_connection("localhost", "root", "123456")
if connection is None:
print("Failed to create a connection to the database. Exiting the script.")
sys.exit(1)
database_name = "test"
create_database(connection, database_name)
query = "CREATE TABLE example_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100))"
execute_query_in_database(connection, database_name, query, 1)
insert_query = "INSERT INTO example_table (name) VALUES ('John Doe')"
execute_query_in_database(connection, database_name, insert_query, 1)
select_query = "SELECT * FROM example_table"
execute_query_in_database(connection, database_name, select_query, count)
time.sleep(1)
if connection.is_connected():
connection.close()
print("The connection is closed") This modification checks if the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Describe the bug
logs: https://github.com/hengyoush/kyanos/actions/runs/13170107381/job/36826916113
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Information (please complete the following information):
uname -ar
]The text was updated successfully, but these errors were encountered: