Replaces all dark-Mocha colours (#1e1e2e base, #313244 surface0, etc.) with the noticeably brighter Frappé variants (#303446 base, #414559 surface0, etc.) across the QSS and every hardcoded colour in Python source files (syntax highlighter, completer popup, log viewer, explain view, table viewer, schema browser, icons, etc.). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
"""
|
|
Connection profile dataclass and registry.
|
|
"""
|
|
from dataclasses import dataclass, field
|
|
import uuid
|
|
|
|
|
|
@dataclass
|
|
class ConnectionProfile:
|
|
name: str
|
|
db_type: str # mysql | postgresql | sqlite | mssql
|
|
host: str = "localhost"
|
|
port: int = 3306
|
|
database: str = ""
|
|
username: str = ""
|
|
password: str = field(default="", repr=False)
|
|
color: str = "#8caaee"
|
|
id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
ssl: bool = False
|
|
ssl_cert: str = ""
|
|
ssl_key: str = ""
|
|
ssl_ca: str = ""
|
|
connection_timeout: int = 30
|
|
|
|
DB_PORTS = {
|
|
"mysql": 3306,
|
|
"postgresql": 5432,
|
|
"sqlite": 0,
|
|
"mssql": 1433,
|
|
}
|
|
|
|
DB_DISPLAY = {
|
|
"mysql": "MySQL",
|
|
"postgresql": "PostgreSQL",
|
|
"sqlite": "SQLite",
|
|
"mssql": "SQL Server",
|
|
}
|
|
|
|
@property
|
|
def db_type_display(self) -> str:
|
|
return self.DB_DISPLAY.get(self.db_type, self.db_type)
|
|
|
|
@property
|
|
def default_port(self) -> int:
|
|
return self.DB_PORTS.get(self.db_type, 0)
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"id": self.id,
|
|
"name": self.name,
|
|
"db_type": self.db_type,
|
|
"host": self.host,
|
|
"port": self.port,
|
|
"database": self.database,
|
|
"username": self.username,
|
|
"color": self.color,
|
|
"ssl": self.ssl,
|
|
"ssl_cert": self.ssl_cert,
|
|
"ssl_key": self.ssl_key,
|
|
"ssl_ca": self.ssl_ca,
|
|
"connection_timeout": self.connection_timeout,
|
|
}
|
|
|
|
@classmethod
|
|
def from_dict(cls, data: dict) -> "ConnectionProfile":
|
|
return cls(
|
|
id=data.get("id", str(uuid.uuid4())),
|
|
name=data.get("name", "Untitled"),
|
|
db_type=data.get("db_type", "mysql"),
|
|
host=data.get("host", "localhost"),
|
|
port=data.get("port", 3306),
|
|
database=data.get("database", ""),
|
|
username=data.get("username", ""),
|
|
color=data.get("color", "#8caaee"),
|
|
ssl=data.get("ssl", False),
|
|
ssl_cert=data.get("ssl_cert", ""),
|
|
ssl_key=data.get("ssl_key", ""),
|
|
ssl_ca=data.get("ssl_ca", ""),
|
|
connection_timeout=data.get("connection_timeout", 30),
|
|
)
|