Issue
I have this command, which works in the shell:
<ABS_PATH>/odbc2parquet query --connection-string "Driver={<DRIVER_NAME>};SERVER=<SERVER_IP>,<SERVER_PORT>;DATABASE=<DB_NAME>;UID=<UID>;PWD=<PWD>" <OUTPUT_PATH> "<QUERY>"
But the following python code doesn't work:
import subprocess
from typing import List
cmd_odbc: List[str] = [
"<ABS_PATH>/odbc2parquet",
"query",
"--connection-string",
'"Driver={<DRIVER_NAME>};SERVER=<SERVER_IP>,<SERVER_PORT>;DATABASE=<DB_NAME>;UID=<UID>;PWD=<PWD>"',
"<OUTPUT_PATH>",
'"<QUERY>"'
]
process_odbc: subprocess.Popen = subprocess.Popen(cmd_odbc)
process_odbc.wait()
This raises the following error:
Error: ODBC emitted an error calling 'SQLDriverConnect':
State: IM002, Native error: 0, Message: [unixODBC][Driver Manager]Data source name not found and no default driver specified
Instead, I have to do the following workaround
import subprocess
from typing import List
cmd_odbc: List[str] = [
"<ABS_PATH>/odbc2parquet",
"query",
"--connection-string",
'"Driver={<DRIVER_NAME>};SERVER=<SERVER_IP>,<SERVER_PORT>;DATABASE=<DB_NAME>;UID=<UID>;PWD=<PWD>"',
"<OUTPUT_PATH>",
'"<QUERY>"'
]
process_odbc: subprocess.Popen = subprocess.Popen(" ".join(cmd_odbc), shell=True)
process_odbc.wait()
Question
Why doesn't the first code work while the second does? What is the main difference here?
Thanks to everyone reading.