initial commit
This commit is contained in:
26
server/test_sql.py
Normal file
26
server/test_sql.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
import pymysql
|
||||
|
||||
load_dotenv()
|
||||
|
||||
try:
|
||||
connection = pymysql.connect(
|
||||
host='localhost',
|
||||
port=3306,
|
||||
user=os.getenv('DB_USER'),
|
||||
password=os.getenv('DB_PASSWORD'),
|
||||
database=os.getenv('DB_NAME')
|
||||
)
|
||||
print("✅ Verbindung erfolgreich!")
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("SELECT VERSION()")
|
||||
version = cursor.fetchone()
|
||||
print(f"MariaDB Version: {version[0]}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Verbindungsfehler: {e}")
|
||||
finally:
|
||||
if 'connection' in locals():
|
||||
connection.close()
|
||||
Reference in New Issue
Block a user