I’m encountering a PermissionError while attempting to use the sqllineage command from within my Node.js application in deployment server in windows 10. Below is the code I’m using.
function analyzeLineage(callback) {
// Execute sqllineage command with the SQL query directly
const demoQuery = `CREATE OR REPLACE TABLE user_orders AS SELECT u.user_id, u.user_name, u.email, o.order_id, o.order_date FROM users u JOIN orders o ON u.user_id = o.user_id;`
exec(`sqllineage -e "${demoQuery}"`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${stderr}`);
callback(error, null);
logger.log({
level: "error",
message: `sqllineage -e analyze lineage : ${error}`,
});
return;
}
callback(null, stdout);
});
}
I’m using sqllineage version 1.5.3. when I tried to execute this command through terminal, It works perfectly at the same location where my project is located but not working from code side.
Here’s the full error message I’m receiving:
{“level”:”error”,”message”:”sqllineage -e analyze lineage : Error:
Command failed: sqllineage -e “CREATE OR REPLACE TABLE user_orders AS
SELECT u.user_id, u.user_name, u.email, o.order_id,
o.order_date FROM users u JOIN orders o ON u.user_id =
o.user_id;”nTraceback (most recent call last):rn File “”, line 198, in _run_module_as_mainrn File “”, line 88, in _run_codern File “C:Program
FilesPython312Scriptssqllineage.exemain.py”, line 7, in
rn File “C:Program
FilesPython312Libsite-packagessqllineagecli.py”, line 127,
in mainrn runner.print_table_lineage()rn File “C:Program
FilesPython312Libsite-packagessqllineagerunner.py”, line
179, in print_table_lineagern print(str(self))rn
^^^^^^^^^rn File “C:Program
FilesPython312Libsite-packagessqllineagerunner.py”, line
26, in wrapperrn self._eval()rn File “C:Program
FilesPython312Libsite-packagessqllineagerunner.py”, line
199, in _evalrn stmt_holder = analyzer.analyze(stmt,
session.metadata_provider)rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rn File
“C:Program
FilesPython312Libsite-packagessqllineagecoreparsersqlfluffanalyzer.py”,
line 52, in analyzern statement_segments =
self._list_specific_statement_segment(sql)rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rn File “C:Program
FilesPython312Libsite-packagessqllineagecoreparsersqlfluffanalyzer.py”,
line 83, in _list_specific_statement_segmentrn
config=FluffConfig.from_root(overrides={“dialect”:
self._dialect})rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rn File
“C:Program
FilesPython312Libsite-packagessqlfluffcoreconfig.py”,
line 873, in from_rootrn c = loader.load_config_up_to_path(rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rn File “C:Program
FilesPython312Libsite-packagessqlfluffcoreconfig.py”,
line 684, in load_config_up_to_pathrn user_config =
self.load_user_config() if not ignore_local_config else {}rn
^^^^^^^^^^^^^^^^^^^^^^^rn File “C:Program
FilesPython312Libsite-packagessqlfluffcoreconfig.py”,
line 672, in load_user_configrn return
self.load_config_at_path(user_home_path)rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rn File “C:Program
FilesPython312Libsite-packagessqlfluffcoreconfig.py”,
line 611, in load_config_at_pathrn d =
os.listdir(os.path.expanduser(p))rn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^rnPermissionError: [WinError 5]
Access is denied:
‘C:\Windows\system32\config’rn”,”timestamp”:”2024-09-03
10:44:56″}
I have tried below steps:
-
I have tried to change the “sqllineage” with location where sqllineage is located in my system. But still not working.
-
I also tried to run this command as administrator in the code.
-
Also checked the permission to allow sqllineage.exe to Run & execute.