Exemplo n.º 1
0
    def action_clear(self, options, args):
        """Clear all the data from database.
        """
        if not options.force:
            ans = raw_input(
                """
Be careful, all the data from database %r will be cleared.
Are you sure about this action? (y/N): """
                % settings.DATABASE_NAME
            )

            if ans.lower() != "y":
                return

        models, __pending = self.get_models()
        models.reverse()
        try:
            for model in models:
                if options.verbose:
                    print "Clear table %r" % model._meta.table
                model.all().delete()
        except:
            database.rollback()
            raise
        else:
            database.commit()
Exemplo n.º 2
0
Arquivo: db.py Projeto: lafada/kalapy
    def action_reset(self, options, args):
        """Reset the model tables. Use with care, will drop all the tables.
        """

        if not options.force:
            ans = raw_input("""
Be careful, all the tables of database %r will be dropped.
All the data stored in the database will be lost too.

Are you sure about this action? (y/N): """ % settings.DATABASE_NAME)

            if ans.lower() != 'y': return

        models, __pending = self.get_models()
        models.reverse()
        try:
            for model in models:
                if options.verbose:
                    print "Drop table %r" % model._meta.table
                database.drop_table(model)
        except:
            database.rollback()
            raise
        else:
            database.commit()

        self.action_sync(options, args)
Exemplo n.º 3
0
    def action_reset(self, options, args):
        """Reset the model tables. Use with care, will drop all the tables.
        """

        if not options.force:
            ans = raw_input("""
Be careful, all the tables of database %r will be dropped.
All the data stored in the database will be lost too.

Are you sure about this action? (y/N): """ % settings.DATABASE_NAME)

            if ans.lower() != 'y': return

        models, __pending = self.get_models()
        models.reverse()
        try:
            for model in models:
                if options.verbose:
                    print "Drop table %r" % model._meta.table
                database.drop_table(model)
        except:
            database.rollback()
            raise
        else:
            database.commit()

        self.action_sync(options, args)
Exemplo n.º 4
0
Arquivo: db.py Projeto: lafada/kalapy
 def action_sync(self, options, args):
     """Create the database tables for all the INSTALLED_PACKAGES whose
     tables haven't been created yet.
     """
     models, __pending = self.get_models()
     try:
         for model in models:
             if options.verbose:
                 print "Sync table %r" % (model._meta.table)
             database.create_table(model)
     except:
         database.rollback()
         raise
     else:
         database.commit()
Exemplo n.º 5
0
 def action_sync(self, options, args):
     """Create the database tables for all the INSTALLED_PACKAGES whose
     tables haven't been created yet.
     """
     models, __pending = self.get_models()
     try:
         for model in models:
             if options.verbose:
                 print "Sync table %r" % (model._meta.table)
             database.create_table(model)
     except:
         database.rollback()
         raise
     else:
         database.commit()
Exemplo n.º 6
0
    def action_clear(self, options, args):
        """Clear all the data from database.
        """
        if not options.force:
            ans = raw_input("""
Be careful, all the data from database %r will be cleared.
Are you sure about this action? (y/N): """ % settings.DATABASE_NAME)

            if ans.lower() != 'y': return

        models, __pending = self.get_models()
        models.reverse()
        try:
            for model in models:
                if options.verbose:
                    print "Clear table %r" % model._meta.table
                model.all().delete()
        except:
            database.rollback()
            raise
        else:
            database.commit()
Exemplo n.º 7
0
Arquivo: db.py Projeto: lafada/kalapy
 def tearDown(self):
     if settings.DATABASE_ENGINE == 'gae':
         from kalapy.admin import execute_command
         execute_command(['database', 'clear', '-f'])
     else:
         database.rollback()