Oct-08-2018, 05:38 PM
Unless you're looking for a different username, this change should do the trick. I don't believe the colon is needed in the SQL statement.
import pandas as pd from pandas import DataFrame from sqlalchemy import create_engine import os import subprocess import sys name = sys.argv[1] os.environ['ORACLE_HOME'] = "/u01/app/oracle/12.1.0.2/db1-base/" os.environ['ORACLE_SID'] = "orcl" os.environ['PATH'] = "/u01/app/oracle/12.1.0.2/db1-base/bin/" oracle_connection_string = 'oracle+cx_oracle://{username}:{password}@{hostname}:{port}/{database}' user = 'system' engine = create_engine( oracle_connection_string.format( username=user, password='Oracle_456', hostname='localhost', port='1521', database='orcl', ) ) sql = 'SELECT USERNAME,ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME = :{name}' data = pd.read_sql_query(sql.format(user),engine) print(data)