Gestion des dossiers sur VPS
This commit is contained in:
17
app/Test_Mysql.py
Normal file
17
app/Test_Mysql.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import os, mysql.connector
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# charge le .env **avec chemin absolu**
|
||||||
|
load_dotenv(Path(__file__).resolve().parent.joinpath(".env"))
|
||||||
|
|
||||||
|
conn = mysql.connector.connect(
|
||||||
|
host=os.getenv("DB_HOST"),
|
||||||
|
user=os.getenv("DB_USER"),
|
||||||
|
password=os.getenv("DB_PASSWORD"),
|
||||||
|
database=os.getenv("DB_NAME"),
|
||||||
|
connection_timeout=5,
|
||||||
|
)
|
||||||
|
conn.ping(reconnect=True, attempts=3, delay=1)
|
||||||
|
print("CONNECTED" if conn.is_connected() else "KO")
|
||||||
|
conn.close()
|
||||||
6
app/generate_admin_hash.py
Normal file
6
app/generate_admin_hash.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import bcrypt
|
||||||
|
|
||||||
|
password = input("Entre le mot de passe admin à hacher : ")
|
||||||
|
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
|
||||||
|
print("\nHash généré :")
|
||||||
|
print(hashed.decode())
|
||||||
Reference in New Issue
Block a user