Source

fabulator / src / fabulator / core / db / base.py

Full commit
# -*- coding: latin-1 -*-
"""



"""

from fabric.api import sudo, run

class BaseDB(object):
    """Base class for database"""

    def __init__(self, conf, env):
        self.conf = conf
        self.env = env

    def create_database(self, database_name=None):
        """create database"""
        raise NotImplementedError

    def backup(self, filename="plop"):
        """backup the database"""
        raise NotImplementedError

    def migrate(self, revision):
        """migrate the database"""
        raise NotImplementedError

    def fallback(self, revision):
        """fallback to an old revision"""
        raise NotImplementedError

    def drop_table(self, table_name):
        """Drop a table"""
        raise NotImplementedError

    def drop_database(self, database_name):
        raise NotImplementedError

    def list_revision(self):
        """Return a list of available database revision"""
        raise NotImplementedError

    def rc(self, service_name, rc_name=None, command="start", require_space=None):
        """manage the daemon using system RC"""
        rc_name = rc_name or "/etc/init.d/"
        service_name = service_name or "mysql"
        if require_space:
            sudo("%s %s %s" % (rc_name, service_name, command))
        sudo("%s/%s %s" % (rc_name, service_name, command))