コード例 #1
0
 def drop_all_tables(cls):
     for scls in Node.__subclasses__():
         try:
             cls.engine.execute("DROP TABLE {} CASCADE"
                                .format(scls.__tablename__))
         except Exception as e:
             cls.logger.warning(e)
コード例 #2
0
 def drop_all_tables(cls):
     for scls in Node.__subclasses__():
         try:
             cls.engine.execute("DROP TABLE {} CASCADE".format(
                 scls.__tablename__))
         except Exception as e:
             cls.logger.warning(e)
コード例 #3
0
def execute_for_all_graph_tables(driver, sql, *args, **kwargs):
    """Execute a SQL statment that has a python format variable {table}
    to be replaced with the tablename for all Node and Edge tables

    """
    for cls in Node.__subclasses__() + Edge.__subclasses__():
        _kwargs = dict(kwargs, **{"table": cls.__tablename__})
        statement = sql.format(**_kwargs)
        execute(driver, statement)
コード例 #4
0
def execute_for_all_graph_tables(engine, sql, *args, **kwargs):
    """Execute a SQL statment that has a python format variable {table}
    to be replaced with the tablename for all Node and Edge tables

    """
    for cls in Node.__subclasses__() + Edge.__subclasses__():
        _kwargs = dict(kwargs, **{'table': cls.__tablename__})
        statement = sql.format(**_kwargs)
        execute(engine, statement)
コード例 #5
0
    def tearDownClass(cls):
        """Recreate the database for tests that follow.

        """
        cls.create_all_tables()

        # Re-grant permissions to test user
        for scls in Node.__subclasses__() + Edge.__subclasses__():
            statment = ("GRANT ALL PRIVILEGES ON TABLE {} TO test".format(
                scls.__tablename__))
            cls.engine.execute('BEGIN; %s; COMMIT;' % statment)
コード例 #6
0
    def tearDownClass(cls):
        """Recreate the database for tests that follow.

        """
        cls.create_all_tables()

        # Re-grant permissions to test user
        for scls in Node.__subclasses__() + Edge.__subclasses__():
            statment = ("GRANT ALL PRIVILEGES ON TABLE {} TO test"
                        .format(scls.__tablename__))
            cls.engine.execute('BEGIN; %s; COMMIT;' % statment)
コード例 #7
0
    def _run(connection):
        create_all(connection)

        # migrate indexes
        exist_index_uniqueness = dict(
            iter(
                connection.execute("SELECT i.relname, ix.indisunique "
                                   "FROM pg_class i, pg_index ix "
                                   "WHERE i.oid = ix.indexrelid")))
        for cls in Node.__subclasses__() + Edge.__subclasses__():
            for index in cls.__table__.indexes:
                uniq = exist_index_uniqueness.get(index.name, None)
                if uniq is None:
                    # create the missing index
                    index.create(connection)
                elif index.unique != uniq:
                    # recreate indexes whose uniqueness changed
                    index.drop(connection)
                    index.create(connection)