Rdeirection BDE
This commit is contained in:
23
TestMysqlConnector.py
Normal file
23
TestMysqlConnector.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import mysql.connector
|
||||
|
||||
try:
|
||||
conn = mysql.connector.connect(
|
||||
host="192.168.1.100",
|
||||
port=3306,
|
||||
user="Michel",
|
||||
password="wuP^wu&6xjx61bh*kjS^",
|
||||
database="TestDB"
|
||||
)
|
||||
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT VERSION();")
|
||||
version = cursor.fetchone()
|
||||
|
||||
print("Connexion OK")
|
||||
print("Version MariaDB :", version[0])
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
except mysql.connector.Error as err:
|
||||
print("Erreur MySQL :", err)
|
||||
Reference in New Issue
Block a user