src/dirbs/cli/db.py
def install_roles(ctx):
    """Creates DIRBS Core PostgreSQL base roles if they don't exist."""
    logger = logging.getLogger('dirbs.db')
    config = common.ensure_config(ctx)
    db_config = copy.copy(config.db_config)
    # Allow install_roles to work even if database doesn't exist by using the postgres DB
    db_config.database = 'postgres'
    with utils.create_db_connection(db_config) as conn, conn.cursor() as cur:
        if not utils.can_db_user_create_roles(conn):
            logger.error('Current PostgreSQL user does not have the CREATEROLE privilege. Please run this command '
                         'as a normal user with the CREATEROLE privilege granted (preferred) or as a superuser')
            sys.exit(1)

        logger.info('Creating DIRBS Core PostgreSQL roles...')
        sql = pkgutil.get_data('dirbs', 'sql/base/roles.sql')
        cur.execute(sql)
        logger.info('Created DIRBS Core PostgreSQL roles')
Creates DIRBS Core PostgreSQL base roles if they don't exist.
Creates DIRBS Core PostgreSQL base roles if they don't exist.
Creates DIRBS Core PostgreSQL base roles if they don ' t exist .
def install_roles(ctx):
    logger = logging.getLogger('dirbs.db')
    config = common.ensure_config(ctx)
    db_config = copy.copy(config.db_config)
    db_config.database = 'postgres'
    with utils.create_db_connection(db_config) as conn, conn.cursor() as cur:
        if not utils.can_db_user_create_roles(conn):
            logger.error('Current PostgreSQL user does not have the CREATEROLE privilege. Please run this command '
                         'as a normal user with the CREATEROLE privilege granted (preferred) or as a superuser')
            sys.exit(1)
        logger.info('Creating DIRBS Core PostgreSQL roles...')
        sql = pkgutil.get_data('dirbs', 'sql/base/roles.sql')
        cur.execute(sql)
        logger.info('Created DIRBS Core PostgreSQL roles')
def install_roles ( ctx ) : logger = logging . getLogger ( 'dirbs.db' ) config = common . ensure_config ( ctx ) db_config = copy . copy ( config . db_config ) db_config . database = 'postgres' with utils . create_db_connection ( db_config ) as conn , conn . cursor ( ) as cur : if not utils . can_db_user_create_roles ( conn ) : logger . error ( 'Current PostgreSQL user does not have the CREATEROLE privilege. Please run this command ' 'as a normal user with the CREATEROLE privilege granted (preferred) or as a superuser' ) sys . exit ( 1 ) logger . info ( 'Creating DIRBS Core PostgreSQL roles...' ) sql = pkgutil . get_data ( 'dirbs' , 'sql/base/roles.sql' ) cur . execute ( sql ) logger . info ( 'Created DIRBS Core PostgreSQL roles' )
Creates DIRBS Core PostgreSQL base roles if they don't exist.
Creates DIRBS Core PostgreSQL base roles if they don ' t exist .
"""Creates DIRBS Core PostgreSQL base roles if they don't exist.""" # Allow install_roles to work even if database doesn't exist by using the postgres DB
ctx