Untitled
import os import shutil import sqlite3 # Chemin vers le template pgAdmin template_path = "C:/AHK/pgadmin4.db.template" appdata_path = os.path.expandvars(r"%APPDATA%\pgAdmin") pgadmin_db_path = os.path.join(appdata_path, "pgadmin4.db") # Création du dossier AppData si nécessaire if not os.path.exists(appdata_path): os.makedirs(appdata_path) print("📁 Dossier AppData de pgAdmin créé.") # Copier le template vers le dossier AppData shutil.copy(template_path, pgadmin_db_path) print("📄 Fichier pgadmin4.db copié depuis le template.") # Connexion à la copie de pgadmin4.db pour insérer le serveur PostgreSQL conn = sqlite3.connect(pgadmin_db_path) cursor = conn.cursor() # Ajout du serveur PostgreSQL cursor.execute(""" INSERT INTO server (id, user_id, servergroup_id, name, host, port, maintenance_db, username, comment, connection_params) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, (1, 1, 1, 'Toto via Delinea', '127.0.0.1', 5432, 'plop', 'postgres', 'Generated by Delinea Secret Server', '{"sslmode": "prefer", "connect_timeout": 10}')) conn.commit() conn.close() print("✅ Serveur PostgreSQL confiuguré ")
Leave a Comment