37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
from services.odoo.connection import OdooConnection
|
|
|
|
|
|
class OdooDatabaseManager:
|
|
def __init__(self, config_path: str = "config/settings.yaml"):
|
|
self.config = OdooConnection(config_path)
|
|
|
|
def get_databases(self, instance_name: str = None) -> list:
|
|
"""Get a list of databases for a specific Odoo instance."""
|
|
print("Fetching databases...")
|
|
|
|
def drop_database(self, instance_name: str, db_name: str) -> None:
|
|
"""Drop a specific database from the Odoo instance."""
|
|
print(f"Dropping database {db_name} from instance {instance_name}...")
|
|
|
|
def create_database(
|
|
self, instance_name: str, db_name: str, demo: bool = False
|
|
) -> None:
|
|
"""Create a new database for the Odoo instance."""
|
|
print(f"Creating database {db_name} for instance {instance_name}...")
|
|
|
|
def backup_database(self, instance_name: str, db_name: str) -> None:
|
|
"""Backup a specific database from the Odoo instance."""
|
|
print(f"Backing up database {db_name} from instance {instance_name}...")
|
|
|
|
def restore_database(
|
|
self, instance_name: str, db_name: str, backup_file: str
|
|
) -> None:
|
|
"""Restore a database from a backup file."""
|
|
print(f"Restoring database {db_name} for instance {instance_name}...")
|
|
|
|
def duplicate_database(
|
|
self, instance_name: str, source_db: str, target_db: str
|
|
) -> None:
|
|
"""Duplicate a database in the Odoo instance."""
|
|
print(f"Duplicating database {source_db} to {target_db}...")
|