-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
53 lines (41 loc) · 1.38 KB
/
check.py
File metadata and controls
53 lines (41 loc) · 1.38 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# import os
# import mysql.connector
# from dotenv import load_dotenv
# # Load environment variables
# load_dotenv() # you can also do load_dotenv(dotenv_path="/full/path/to/.env")
# DB_HOST = os.getenv("DB_HOST")
# DB_PORT = os.getenv("DB_PORT")
# DB_USER = os.getenv("DB_USER")
# DB_PASSWORD = os.getenv("DB_PASSWORD")
# DB_NAME = os.getenv("DB_NAME")
# print("🔍 Loaded environment variables:")
# print(f"DB_HOST={DB_HOST}")
# print(f"DB_PORT={DB_PORT}")
# print(f"DB_USER={DB_USER}")
# print(f"DB_PASSWORD={DB_PASSWORD}")
# print(f"DB_NAME={DB_NAME}")
# try:
# connection = mysql.connector.connect(
# host=DB_HOST,
# port=DB_PORT,
# user=DB_USER,
# password=DB_PASSWORD
# )
# if connection.is_connected():
# print(f"✅ Connected to MySQL at {DB_HOST}:{DB_PORT}")
# cursor = connection.cursor()
# cursor.execute("SHOW DATABASES")
# print("\n📂 Databases:")
# for db in cursor.fetchall():
# print(f"- {db[0]}")
# except mysql.connector.Error as err:
# print(f"❌ Error: {err}")
# finally:
# if 'connection' in locals() and connection.is_connected():
# cursor.close()
# connection.close()
# print("\n🔌 MySQL connection closed.")
from dotenv import load_dotenv
import os
load_dotenv() # this reads .env file
print("Database URL:", os.getenv("DATABASE_URL"))