synapse/storage/prepare_database.py
def _apply_module_schema_files(cur, database_engine, modname, names_and_streams):
    """Apply the module schemas for a single module

    Args:
        cur: database cursor
        database_engine: synapse database engine class
        modname (str): fully qualified name of the module
        names_and_streams (Iterable[(str, file)]): the names and streams of
            schemas to be applied
    """
    cur.execute(
        database_engine.convert_param_style(
            "SELECT file FROM applied_module_schemas WHERE module_name = ?"
        ),
        (modname,)
    )
    applied_deltas = set(d for d, in cur)
    for (name, stream) in names_and_streams:
        if name in applied_deltas:
            continue

        root_name, ext = os.path.splitext(name)
        if ext != '.sql':
            raise PrepareDatabaseException(
                "only .sql files are currently supported for module schemas",
            )

        logger.info("applying schema %s for %s", name, modname)
        for statement in get_statements(stream):
            cur.execute(statement)

        # Mark as done.
        cur.execute(
            database_engine.convert_param_style(
                "INSERT INTO applied_module_schemas (module_name, file)"
                " VALUES (?,?)",
            ),
            (modname, name)
        )
Apply the module schemas for a single module

    Args:
        cur: database cursor
        database_engine: synapse database engine class
        modname (str): fully qualified name of the module
        names_and_streams (Iterable[(str, file)]): the names and streams of
            schemas to be applied
    
Apply the module schemas for a single module
Apply the module schemas for a single module
def _apply_module_schema_files(cur, database_engine, modname, names_and_streams):
    cur.execute(
        database_engine.convert_param_style(
            "SELECT file FROM applied_module_schemas WHERE module_name = ?"
        ),
        (modname,)
    )
    applied_deltas = set(d for d, in cur)
    for (name, stream) in names_and_streams:
        if name in applied_deltas:
            continue
        root_name, ext = os.path.splitext(name)
        if ext != '.sql':
            raise PrepareDatabaseException(
                "only .sql files are currently supported for module schemas",
            )
        logger.info("applying schema %s for %s", name, modname)
        for statement in get_statements(stream):
            cur.execute(statement)
        cur.execute(
            database_engine.convert_param_style(
                "INSERT INTO applied_module_schemas (module_name, file)"
                " VALUES (?,?)",
            ),
            (modname, name)
        )
def _apply_module_schema_files ( cur , database_engine , modname , names_and_streams ) : cur . execute ( database_engine . convert_param_style ( "SELECT file FROM applied_module_schemas WHERE module_name = ?" ) , ( modname , ) ) applied_deltas = set ( d for d , in cur ) for ( name , stream ) in names_and_streams : if name in applied_deltas : continue root_name , ext = os . path . splitext ( name ) if ext != '.sql' : raise PrepareDatabaseException ( "only .sql files are currently supported for module schemas" , ) logger . info ( "applying schema %s for %s" , name , modname ) for statement in get_statements ( stream ) : cur . execute ( statement ) cur . execute ( database_engine . convert_param_style ( "INSERT INTO applied_module_schemas (module_name, file)" " VALUES (?,?)" , ) , ( modname , name ) )
Apply the module schemas for a single module
Apply the module schemas for a single module
"""Apply the module schemas for a single module

    Args:
        cur: database cursor
        database_engine: synapse database engine class
        modname (str): fully qualified name of the module
        names_and_streams (Iterable[(str, file)]): the names and streams of
            schemas to be applied
    """ # Mark as done.
cur
None
database_engine
synapse database engine class
synapse database engine class
modname
fully qualified name of the module
fully qualified name of the module
names_and_streams
the names and streams of
schemas to be applied
the names and streams of schemas to be applied