Spaces:
Running
Running
File size: 735 Bytes
ac40033 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import mysql.connector
from mysql.connector import Error
config = {
"host": "annotation-db.apps.teh2.abrhapaas.com",
"user": "navid",
"password": "ZUJSK!1V!PF4ZEnIaylX",
"charset": "utf8mb4",
"port": 32107,
"use_unicode": True
}
try:
conn = mysql.connector.connect(**config)
if conn.is_connected():
print("✅OK!")
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
version = cursor.fetchone()
print("🟢MySQL Server Version:", version[0])
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.") |