tts_labeling / test /db_test.py
Navid Arabi
base app
1ef4e10
raw
history blame
655 Bytes
import mysql.connector
from mysql.connector import Error
import config
try:
conn = mysql.connector.connect(**config.db_config)
if conn.is_connected():
print("✅OK!")
cursor = conn.cursor()
cursor.execute("SELECT id, filename, sentence FROM tts_data ORDER BY id DESC LIMIT 5")
records = cursor.fetchall()
print("🟢Last 5 records:")
for record in records:
print(record)
except Error as e:
print("❌ error:", e)
finally:
if 'cursor' in locals():
cursor.close()
if 'conn' in locals() and conn.is_connected():
conn.close()
print("⛔️Closed.")